3 namespace Drupal\config_translation\Controller;
5 use Drupal\config_translation\ConfigMapperManagerInterface;
6 use Drupal\Core\Controller\ControllerBase;
7 use Symfony\Component\DependencyInjection\ContainerInterface;
8 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
11 * Defines the configuration translation list controller.
13 class ConfigTranslationListController extends ControllerBase {
18 * @var \Drupal\config_translation\ConfigMapperManagerInterface
20 protected $mapperManager;
23 * Constructs a new ConfigTranslationListController object.
25 * @param \Drupal\config_translation\ConfigMapperManagerInterface $mapper_manager
26 * The config mapper manager.
28 public function __construct(ConfigMapperManagerInterface $mapper_manager) {
29 $this->mapperManager = $mapper_manager;
35 public static function create(ContainerInterface $container) {
37 $container->get('plugin.manager.config_translation.mapper')
42 * Provides the listing page for any entity type.
44 * @param string $mapper_id
45 * The name of the mapper.
48 * A render array as expected by
49 * \Drupal\Core\Render\RendererInterface::render().
51 * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
52 * Throws an exception if a mapper plugin could not be instantiated from the
53 * mapper definition in the constructor.
55 public function listing($mapper_id) {
56 $mapper_definition = $this->mapperManager->getDefinition($mapper_id);
57 $mapper = $this->mapperManager->createInstance($mapper_id, $mapper_definition);
59 throw new NotFoundHttpException();
61 $entity_type = $mapper->getType();
62 // If the mapper, for example the mapper for fields, has a custom list
63 // controller defined, use it. Other mappers, for examples the ones for
64 // node_type and block, fallback to the generic configuration translation
66 $build = $this->entityManager()
67 ->getHandler($entity_type, 'config_translation_list')
68 ->setMapperDefinition($mapper_definition)
70 $build['#title'] = $mapper->getTypeLabel();