You are here

function layout_builder_at_install in Layout Builder Asymmetric Translation 8.2

Implements hook_install().

File

./layout_builder_at.install, line 12

Code

function layout_builder_at_install() {

  // Makes all existing layout_section field translatable.
  if (!\Drupal::service('config.installer')
    ->isSyncing()) {

    /** @var \Drupal\field\FieldStorageConfigInterface $field_storage_config */
    foreach (\Drupal::entityTypeManager()
      ->getStorage('field_storage_config')
      ->loadMultiple() as $field_storage_config) {

      // Only act on layout builder section fields.
      if ($field_storage_config
        ->getType() === 'layout_section' && $field_storage_config
        ->getName() === OverridesSectionStorage::FIELD_NAME) {

        // Call save. layout_builder_at_field_storage_config_presave() will make
        // the field translatable.
        $field_storage_config
          ->save();
      }
    }
  }
}