function config_translation_entity_type_alter

Same name and namespace in other branches
  1. 9 core/modules/config_translation/config_translation.module \config_translation_entity_type_alter()
  2. 8.9.x core/modules/config_translation/config_translation.module \config_translation_entity_type_alter()
  3. 11.x core/modules/config_translation/config_translation.module \config_translation_entity_type_alter()

Implements hook_entity_type_alter().

File

core/modules/config_translation/config_translation.module, line 77

Code

function config_translation_entity_type_alter(array &$entity_types) {
    
    /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
    foreach ($entity_types as $entity_type_id => $entity_type) {
        if ($entity_type->entityClassImplements(ConfigEntityInterface::class)) {
            if ($entity_type_id == 'block') {
                $class = 'Drupal\\config_translation\\Controller\\ConfigTranslationBlockListBuilder';
            }
            elseif ($entity_type_id == 'field_config') {
                $class = 'Drupal\\config_translation\\Controller\\ConfigTranslationFieldListBuilder';
                // Will be filled in dynamically, see \Drupal\field\Entity\FieldConfig::linkTemplates().
                $entity_type->setLinkTemplate('config-translation-overview', $entity_type->getLinkTemplate('edit-form') . '/translate');
            }
            else {
                $class = 'Drupal\\config_translation\\Controller\\ConfigTranslationEntityListBuilder';
            }
            $entity_type->setHandlerClass('config_translation_list', $class);
            if ($entity_type->hasLinkTemplate('edit-form')) {
                $entity_type->setLinkTemplate('config-translation-overview', $entity_type->getLinkTemplate('edit-form') . '/translate');
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.