class ConfigTranslationListController
Same name and namespace in other branches
- 10 core/modules/config_translation/src/Controller/ConfigTranslationListController.php \Drupal\config_translation\Controller\ConfigTranslationListController
- 11.x core/modules/config_translation/src/Controller/ConfigTranslationListController.php \Drupal\config_translation\Controller\ConfigTranslationListController
- 8.9.x core/modules/config_translation/src/Controller/ConfigTranslationListController.php \Drupal\config_translation\Controller\ConfigTranslationListController
Defines the configuration translation list controller.
Hierarchy
- class \Drupal\Core\Controller\ControllerBase implements \Drupal\Core\DependencyInjection\ContainerInjectionInterface uses \Drupal\Core\Logger\LoggerChannelTrait, \Drupal\Core\Messenger\MessengerTrait, \Drupal\Core\Routing\RedirectDestinationTrait, \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\config_translation\Controller\ConfigTranslationListController extends \Drupal\Core\Controller\ControllerBase
Expanded class hierarchy of ConfigTranslationListController
File
-
core/
modules/ config_translation/ src/ Controller/ ConfigTranslationListController.php, line 13
Namespace
Drupal\config_translation\ControllerView source
class ConfigTranslationListController extends ControllerBase {
/**
* The mapper manager.
*
* @var \Drupal\config_translation\ConfigMapperManagerInterface
*/
protected $mapperManager;
/**
* Constructs a new ConfigTranslationListController object.
*
* @param \Drupal\config_translation\ConfigMapperManagerInterface $mapper_manager
* The config mapper manager.
*/
public function __construct(ConfigMapperManagerInterface $mapper_manager) {
$this->mapperManager = $mapper_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('plugin.manager.config_translation.mapper'));
}
/**
* Provides the listing page for any entity type.
*
* @param string $mapper_id
* The name of the mapper.
*
* @return array
* A render array as expected by
* \Drupal\Core\Render\RendererInterface::render().
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* Throws an exception if a mapper plugin could not be instantiated from the
* mapper definition in the constructor.
*/
public function listing($mapper_id) {
$mapper_definition = $this->mapperManager
->getDefinition($mapper_id);
$mapper = $this->mapperManager
->createInstance($mapper_id, $mapper_definition);
if (!$mapper) {
throw new NotFoundHttpException();
}
$entity_type = $mapper->getType();
// If the mapper, for example the mapper for fields, has a custom list
// controller defined, use it. Other mappers, for examples the ones for
// node_type and block, fallback to the generic configuration translation
// list controller.
$build = $this->entityTypeManager()
->getHandler($entity_type, 'config_translation_list')
->setMapperDefinition($mapper_definition)
->render();
$build['#title'] = $mapper->getTypeLabel();
return $build;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.