clients.install in Web Service Clients 6.2
Same filename and directory in other branches
Install, update and uninstall functions for the Clients module.
File
clients.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Clients module.
*/
/**
* Implementation of hook_install().
*/
function clients_install() {
drupal_install_schema('clients');
}
/**
* Implementation of hook_uninstall().
*/
function clients_uninstall() {
drupal_uninstall_schema('clients');
// clean up any variables created by module
$module_variables = array();
foreach ($module_variables as $module_variable) {
variable_del($module_variables);
}
}
/**
* Implementation of hook_schema
*/
function clients_schema() {
$schema['cache_clients'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['clients_connections'] = array(
'description' => 'Stores service connection configurations',
// CTools exportables support:
'export' => array(
'key' => 'name',
'key name' => 'Name',
'primary key' => 'cid',
'identifier' => 'connection',
// Exports will be as $myobj
'default hook' => 'clients_default_connections',
// Function hook name.
'export type string' => 'export_type_label',
'object factory' => 'clients_connection_unpack_object',
'export callback' => 'clients_export_object',
'api' => array(
'owner' => 'clients',
'api' => 'clients',
// Base name for api include files.
'minimum_version' => 3,
'current_version' => 3,
),
),
'fields' => array(
'cid' => array(
'description' => 'The primary identifier for a service connection.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
'no export' => TRUE,
),
'name' => array(
'description' => 'Connection name, must be unique',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
),
'type' => array(
'description' => 'Connection type',
'type' => 'varchar',
'length' => 64,
),
'endpoint' => array(
'description' => 'Connection endpoint',
'type' => 'varchar',
'length' => 256,
),
'configuration' => array(
'description' => 'Connection configuration - serialized',
'serialize' => TRUE,
'size' => 'big',
'type' => 'text',
),
),
'unique keys' => array(
'name' => array(
'name',
),
),
'primary key' => array(
'cid',
),
);
return $schema;
}
/**
* Helper function for connection type modules to delete all their connections.
*
* For example usage, see clients_drupal_uninstall().
*
* @param $module
* The name of the module whose connections should be deleted.
*/
function clients_connection_uninstall_connection_delete($module) {
// Invoke hook_clients_connection_type_info().
// This works even when the module is about to be uninstalled.
$connection_types = module_invoke($module, 'clients_connection_type_info');
foreach ($connection_types as $type => $info) {
db_query("DELETE FROM {clients_connections} WHERE type = '%s'", $type);
}
}
Functions
Name | Description |
---|---|
clients_connection_uninstall_connection_delete | Helper function for connection type modules to delete all their connections. |
clients_install | Implementation of hook_install(). |
clients_schema | Implementation of hook_schema |
clients_uninstall | Implementation of hook_uninstall(). |