You are here

function thunder_riddle_update_8001 in Thunder 8.5

Same name and namespace in other branches
  1. 8.3 modules/thunder_article/modules/thunder_riddle/thunder_riddle.install \thunder_riddle_update_8001()
  2. 8.4 modules/thunder_article/modules/thunder_riddle/thunder_riddle.install \thunder_riddle_update_8001()

Add dependency on thunder_riddle where necessary.

File

modules/thunder_riddle/thunder_riddle.install, line 48
Thunder Riddle integration install hooks.

Code

function thunder_riddle_update_8001() {

  /** @var \Drupal\Core\Config\ConfigManager $config_manager */
  $config_manager = \Drupal::service('config.manager');
  $config_entities = [
    'core.entity_form_display.media.riddle.default',
    'core.entity_form_display.paragraph.riddle.default',
    'core.entity_view_display.media.riddle.default',
    'core.entity_view_display.media.riddle.thumbnail',
    'core.entity_view_display.paragraph.riddle.default',
    'core.entity_view_display.paragraph.riddle.preview',
    'entity_browser.browser.riddle_browser',
    'field.field.paragraph.riddle.field_riddle',
    'field.storage.media.field_riddle_id',
    'field.storage.paragraph.field_riddle',
    'media.type.riddle',
    'paragraphs.paragraphs_type.riddle',
  ];
  $new_dependency = [
    'enforced' => [
      'module' => [
        'thunder_riddle',
      ],
    ],
  ];
  foreach ($config_entities as $name) {

    /** @var \Drupal\Core\Config\Entity\ConfigEntityBase $entity */
    $entity = $config_manager
      ->loadConfigEntityByName($name);

    // It's possible a user might have deleted one of the provided entities.
    if ($entity) {
      $dependencies = array_merge($entity
        ->get('dependencies'), $new_dependency);
      $entity
        ->set('dependencies', $dependencies)
        ->trustData()
        ->save();
    }
  }
}