function layout_builder_st_install in Layout Builder Symmetric Translations 8
Implements hook_install().
File
- ./
layout_builder_st.install, line 11
Code
function layout_builder_st_install() {
// Add the layout translation settings field.
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $field_manager */
$field_manager = \Drupal::service('entity_field.manager');
$field_map = $field_manager
->getFieldMap();
foreach ($field_map as $entity_type_id => $field_infos) {
if (isset($field_infos[\Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage::FIELD_NAME]['bundles'])) {
$non_translatable_bundle_count = 0;
foreach ($field_infos[OverridesSectionStorage::FIELD_NAME]['bundles'] as $bundle) {
$bundles_not_added = [];
// The field map can contain stale information. If the field does not
// exist, ignore it. The field map will be rebuilt when the cache is
// cleared at the end of the update process.
if (!($field_config = FieldConfig::loadByName($entity_type_id, $bundle, OverridesSectionStorage::FIELD_NAME))) {
continue;
}
_layout_builder_st_add_translation_field($entity_type_id, $bundle);
}
}
}
}