You are here

restful.install in RESTful 7.2

Same filename and directory in other branches
  1. 7 restful.install

Install, update, and uninstall functions for the RESTful module.

File

restful.install
View source
<?php

/**
 * @file
 * Install, update, and uninstall functions for the RESTful module.
 */

/**
 * Implements hook_schema().
 */
function restful_schema() {
  $schema = array();
  $schema['cache_restful'] = drupal_get_schema_unprocessed('system', 'cache');

  // Rate limit entity base table.
  $schema['restful_rate_limit'] = array(
    'description' => 'Rate limit base table',
    'fields' => array(
      'rlid' => array(
        'description' => 'The rate limit unique ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'event' => array(
        'description' => 'The event name.',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'identifier' => array(
        'description' => 'The user & request identifier.',
        'type' => 'varchar',
        'length' => 128,
        'not null' => TRUE,
        'default' => '',
      ),
      'timestamp' => array(
        'description' => 'The Unix timestamp when the rate limit window started.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'expiration' => array(
        'description' => 'The Unix timestamp when the rate limit window expires.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => NULL,
      ),
      'hits' => array(
        'description' => 'The number of hits.',
        'type' => 'int',
        'not null' => FALSE,
        'default' => 0,
      ),
    ),
    'unique keys' => array(
      'identifier' => array(
        'identifier',
      ),
    ),
    'indexes' => array(
      'rate_limit_identifier' => array(
        'identifier',
      ),
    ),
    'primary key' => array(
      'rlid',
    ),
  );

  // Cache fragment entity base table.
  $schema['restful_cache_fragment'] = array(
    'description' => 'Cache fragment base table',
    'fields' => array(
      'tid' => array(
        'description' => 'The cache fragment unique ID.',
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'type' => array(
        'description' => 'The type of the cache fragment, e.g "entity_id".',
        'type' => 'varchar',
        'length' => 64,
        'not null' => TRUE,
        'default' => '',
      ),
      'value' => array(
        'description' => 'The value for the tag. Example: 182.',
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
        'default' => '',
      ),
      'hash' => array(
        'description' => 'The hash used as a cache ID.',
        'type' => 'char',
        'length' => 40,
        'not null' => FALSE,
        'default' => NULL,
      ),
    ),
    'indexes' => array(
      'cache_fragment_hash' => array(
        'hash',
      ),
    ),
    'unique keys' => array(
      'hash_key_val' => array(
        'type',
        'value',
        'hash',
      ),
    ),
    'primary key' => array(
      'tid',
    ),
  );
  return $schema;
}

/**
 * Implements hook_uninstall().
 */
function restful_uninstall() {
  variable_del('restful_default_output_formatter');
  variable_del('restful_enable_discovery_resource');
  variable_del('restful_file_upload');
  variable_del('restful_file_upload_allow_anonymous_user');
  variable_del('restful_hijack_api_pages');
  variable_del('restful_hook_menu_base_path');
  variable_del('restful_enable_user_login_resource');
  variable_del('restful_global_rate_limit');
  variable_del('restful_global_rate_period');
  variable_del('restful_enable_users_resource');
  variable_del('restful_render_cache');
  variable_del('restful_skip_basic_auth');
  variable_del('restful_allowed_origin');
}

/**
 * Create the cache fragments schema.
 */
function restful_update_7200() {
  $table_schema = drupal_get_schema('restful_cache_fragment', TRUE);
  db_create_table('restful_cache_fragment', $table_schema);
}

/**
 * Clear RESTful cache on cache flush.
 */
function restful_update_7201() {

  // Even if the recommended value is FALSE, there might be some deploy
  // workflows that assume cache clearing.
  variable_set('restful_clear_on_cc_all', TRUE);
}

Functions

Namesort descending Description
restful_schema Implements hook_schema().
restful_uninstall Implements hook_uninstall().
restful_update_7200 Create the cache fragments schema.
restful_update_7201 Clear RESTful cache on cache flush.