You are here

function entity_hierarchy_install in Entity Reference Hierarchy 8

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.

File

./entity_hierarchy.install, line 62
schema and uninstall functions for the entity_hierarchy module.

Code

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();
}