You are here

lightning_page.module in Lightning Core 8

File

modules/lightning_page/lightning_page.module
View source
<?php

use Drupal\field\FieldConfigInterface;

/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function lightning_page_field_config_insert(FieldConfigInterface $field) {

  // Don't do anything during config sync.
  if (\Drupal::isConfigSyncing()) {
    return;
  }
  elseif ($field
    ->id() == 'node.page.field_meta_tags') {
    entity_get_display('node', 'page', 'default')
      ->setComponent('field_meta_tags', [
      'type' => 'metatag_empty_formatter',
      'region' => 'content',
    ])
      ->save();
    entity_get_form_display('node', 'page', 'default')
      ->setComponent('field_meta_tags', [
      'type' => 'metatag_firehose',
      'region' => 'content',
    ])
      ->save();
  }
}