entityreference.install in Entity reference 8
Same filename and directory in other branches
Install, update and uninstall functions for the Entity reference module.
File
entityreference.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the Entity reference
* module.
*/
/**
* Implements hook_field_schema().
*/
function entityreference_field_schema($field) {
$schema = array(
'columns' => array(
'target_id' => array(
'description' => 'The id of the target entity.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
),
'indexes' => array(
'target_id' => array(
'target_id',
),
),
'foreign keys' => array(),
);
// Create a foreign key to the target entity type base type.
$entity_type = $field['settings']['target_type'];
$entity_info = entity_get_info($entity_type);
$base_table = $entity_info['base table'];
$id_column = $entity_info['entity keys']['id'];
$schema['foreign keys'][$base_table] = array(
'table' => $base_table,
'columns' => array(
'target_id' => $id_column,
),
);
return $schema;
}
Functions
Name | Description |
---|---|
entityreference_field_schema | Implements hook_field_schema(). |