schemadotorg_starterkit_podcast-1.0.x-dev/schemadotorg_starterkit_podcast.install

schemadotorg_starterkit_podcast.install
<?php

/**
 * @file
 * Installation hooks for the Schema.org Blueprints: Podcast Starter Kit module.
 */

declare(strict_types=1);

use Drupal\Component\Serialization\Yaml;

/**
 * Implements hook_install().
 */
function schemadotorg_starterkit_podcast_install(bool $is_syncing): void {
  // Force installation of optional config.
  $module_path = \Drupal::service('extension.list.module')
    ->getPath('schemadotorg_starterkit_podcast');
  $config_names = ['auto_entitylabel.settings.node.podcast_episode'];
  foreach ($config_names as $config_name) {
    $data = Yaml::decode(file_get_contents("$module_path/config/optional/$config_name.yml"));
    \Drupal::configFactory()->getEditable($config_name)->setData($data)->save();
  }

  // Remove EVA from the podcast series view displays.
  /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository */
  $entity_display_repository = \Drupal::service('entity_display.repository');
  $view_modes = $entity_display_repository->getViewModeOptionsByBundle('node', 'podcast_series');
  unset($view_modes['default']);
  foreach (array_keys($view_modes) as $view_mode) {
    $view_display = $entity_display_repository->getViewDisplay('node', 'podcast_series', $view_mode);
    $view_display->removeComponent('podcast_episodes_entity_view_1');
    $view_display->save();
  }

  // Add Podcasts default shortcut.
  if (\Drupal::moduleHandler()->moduleExists('shortcut')) {
    /** @var \Drupal\shortcut\ShortcutSetStorageInterface $shortcut_storage */
    $shortcut_storage = \Drupal::entityTypeManager()
      ->getStorage('shortcut');
    if (!$shortcut_storage->loadByProperties(['title' => 'Podcasts'])) {
      $shortcut_storage->create([
        'shortcut_set' => 'default',
        'title' => 'Podcasts',
        'link' => ['uri' => 'internal:/podcasts'],
        'weight' => -10,
      ])->save();
    }
  }
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc