entity_reference_multiple.install in Entity Reference Multiple 7.2
Same filename and directory in other branches
Install, update, and uninstall functions for the Entity Reference Multiple.
File
entity_reference_multiple.installView source
<?php
/**
* @file
* Install, update, and uninstall functions for the Entity Reference Multiple.
*/
/**
* Implements hook_field_schema().
*/
function entity_reference_multiple_field_schema($field) {
if ($field['type'] == 'entity_reference_multiple') {
// Load the base table configuration from the cache.
$base_tables = variable_get('entity_reference_multiple:base-tables', array());
$schema = array(
'columns' => array(
'target_id' => array(
'description' => 'The id of the target entity.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'target_type' => array(
'description' => 'The type of the target entity.',
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
),
'indexes' => array(
'target_id' => array(
'target_id',
),
),
'foreign keys' => array(),
);
// Create a foreign key to the target entity type base type, if available.
$entity_types = $field['settings']['target_types'];
foreach ($entity_types as $entity_type) {
if (isset($base_tables[$entity_type])) {
list($base_table, $id_column) = $base_tables[$entity_type];
$schema['foreign keys'][$base_table] = array(
'table' => $base_table,
'columns' => array(
'target_id' => $id_column,
),
);
}
}
return $schema;
}
}
/**
* Implements hook_uninstall().
*/
function entity_reference_multiple_uninstall() {
variable_del('entity_reference_multiple:base-tables');
variable_del('entity_reference_multiple:short-codes');
}
Functions
Name![]() |
Description |
---|---|
entity_reference_multiple_field_schema | Implements hook_field_schema(). |
entity_reference_multiple_uninstall | Implements hook_uninstall(). |