function _content_translation_install_field_storage_definitions
Same name in other branches
- 9 core/modules/content_translation/content_translation.module \_content_translation_install_field_storage_definitions()
- 8.9.x core/modules/content_translation/content_translation.module \_content_translation_install_field_storage_definitions()
- 10 core/modules/content_translation/content_translation.module \_content_translation_install_field_storage_definitions()
Installs Content Translation's fields for a given entity type.
@todo Generalize this code in https://www.drupal.org/node/2346013.
Parameters
string $entity_type_id: The entity type ID.
2 calls to _content_translation_install_field_storage_definitions()
- content_translation_language_content_settings_insert in core/
modules/ content_translation/ content_translation.module - Implements hook_ENTITY_TYPE_insert().
- content_translation_language_content_settings_update in core/
modules/ content_translation/ content_translation.module - Implements hook_ENTITY_TYPE_update().
File
-
core/
modules/ content_translation/ content_translation.module, line 225
Code
function _content_translation_install_field_storage_definitions($entity_type_id) {
/** @var \Drupal\Core\Entity\EntityFieldManagerInterface $field_manager */
$field_manager = \Drupal::service('entity_field.manager');
/** @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $schema_repository */
$schema_repository = \Drupal::service('entity.last_installed_schema.repository');
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$field_manager->useCaches(FALSE);
$storage_definitions = $field_manager->getFieldStorageDefinitions($entity_type_id);
$field_manager->useCaches(TRUE);
$installed_storage_definitions = $schema_repository->getLastInstalledFieldStorageDefinitions($entity_type_id);
foreach (array_diff_key($storage_definitions, $installed_storage_definitions) as $storage_definition) {
/** @var \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition */
if ($storage_definition->getProvider() == 'content_translation') {
$definition_update_manager->installFieldStorageDefinition($storage_definition->getName(), $entity_type_id, 'content_translation', $storage_definition);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.