You are here

function domain_menu_access_install in Domain Menu Access 8

Implements hook_install().

File

./domain_menu_access.install, line 11
Install, update and uninstall functions for the Domain Menu Access module.

Code

function domain_menu_access_install() {
  $text = [];
  $text['menu_link_content'] = [
    'name' => 'menu_link_content',
    'label' => 'Send for all affiliates',
    'description' => 'Make this menu entry available on all domains.',
  ];
  $entity_type = $bundle = 'menu_link_content';

  /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $entity_form_display_storage */
  $entity_form_display_storage = \Drupal::entityTypeManager()
    ->getStorage('entity_form_display');

  // By default, form display for menu_content_link entity doesn't exists.
  // We should create "default" form display for entity type to ensure that's
  // domain access fields will be successfully added.
  if (!$entity_form_display_storage
    ->load($entity_type . '.' . $bundle . '.default')) {
    $display = $entity_form_display_storage
      ->create([
      'targetEntityType' => $entity_type,
      'bundle' => $bundle,
      'mode' => 'default',
      'status' => TRUE,
    ]);
    $display
      ->save();
  }
  domain_access_confirm_fields($entity_type, $bundle, $text);
}