entity_hierarchy.install in Entity Reference Hierarchy 8
schema and uninstall functions for the entity_hierarchy module.
File
entity_hierarchy.installView source
<?php
/**
* @file
* schema and uninstall functions for the entity_hierarchy module.
*/
/**
* Implements hook_schema().
*/
function entity_hierarchy_schema() {
$schema['entity_hierarchy'] = array(
'description' => 'The hierarchical structure of the nodes.',
'fields' => array(
'hid' => array(
'description' => 'A unique identifier for this relationship.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'pnid' => array(
'description' => 'The {node}.nid of the parent.',
'type' => 'int',
'not null' => FALSE,
),
'cnid' => array(
'description' => 'The {node}.nid whose parent is being defined.',
'type' => 'int',
'not null' => FALSE,
),
'pweight' => array(
'description' => 'The weight of the parent.',
'type' => 'int',
'not null' => FALSE,
),
'cweight' => array(
'description' => 'The weight of the child.',
'type' => 'int',
'not null' => FALSE,
),
'mlid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => "The node's {menu_links}.mlid if any.",
),
),
'primary key' => array(
'hid',
),
);
return $schema;
}
/**
* Implements hook_install().
*
* Set the default values for all content types in this hook. Since we don't
* know what content types are available prior to installation, this must be
* done dynamically instead of providing an entity_hierarchy.settings.yml file.
* See https://www.drupal.org/node/2120571 for more information.
*/
function entity_hierarchy_install() {
// Set default values for config which require dynamic values.
$config = \Drupal::configFactory()
->getEditable('entity_hierarchy.settings');
foreach (node_type_get_names() as $key => $type) {
$config
->set('nh_allowchild_' . $key, 0);
}
$config
->save();
}
Functions
Name | Description |
---|---|
entity_hierarchy_install | Implements hook_install(). |
entity_hierarchy_schema | Implements hook_schema(). |