schemadotorg_starterkit_layout-1.0.x-dev/schemadotorg_starterkit_layout.install

schemadotorg_starterkit_layout.install
<?php

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

declare(strict_types=1);

use Drupal\schemadotorg\SchemaDotOrgMappingInterface;

/**
 * Implements hook_install().
 */
function schemadotorg_starterkit_layout_install(bool $is_syncing): void {
  if ($is_syncing) {
    return;
  }

  // Add field prefix and suffix support to the 'layout' component.
  /** @var \Drupal\schemadotorg\SchemaDotOrgMappingStorageInterface $mapping_storage */
  $mapping_storage = \Drupal::entityTypeManager()->getStorage('schemadotorg_mapping');
  $mapping = $mapping_storage->load('paragraph.layout');
  if ($mapping instanceof SchemaDotOrgMappingInterface) {
    schemadotorg_field_parts_schemadotorg_mapping_presave($mapping);
  }

  // Hide labels for all schema_* field in paragraph view displays.
  $default_paragraph_types = \Drupal::config('schemadotorg_layout_paragraphs.settings')
    ->get('default_paragraph_types');
  /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository */
  $entity_display_repository = \Drupal::service('entity_display.repository');
  foreach ($default_paragraph_types as $default_paragraph_type) {
    $display = $entity_display_repository->getViewDisplay('paragraph', $default_paragraph_type);
    $components = $display->getComponents();
    foreach ($components as $field_name => $component) {
      if (str_starts_with($field_name, 'schema_')) {
        $component['label'] = 'hidden';
        $display->setComponent($field_name, $component);
      }
    }
    $display->save();
  }

  // Update Mercury Editor form display after the config rewrite is triggered.
  /** @var \Drupal\mercury_editor_task\MercuryEditorTaskFormDisplayBuilderInterface $form_display_builder */
  $form_display_builder = \Drupal::service('mercury_editor_task.form_display_builder');
  $form_display_builder->updateContentTypes(TRUE);
}

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

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