You are here

public function ConfigTranslationListController::listing in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/config_translation/src/Controller/ConfigTranslationListController.php \Drupal\config_translation\Controller\ConfigTranslationListController::listing()

Provides the listing page for any entity type.

Parameters

string $mapper_id: The name of the mapper.

Return value

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.

1 string reference to 'ConfigTranslationListController::listing'
config_translation.routing.yml in core/modules/config_translation/config_translation.routing.yml
core/modules/config_translation/config_translation.routing.yml

File

core/modules/config_translation/src/Controller/ConfigTranslationListController.php, line 55

Class

ConfigTranslationListController
Defines the configuration translation list controller.

Namespace

Drupal\config_translation\Controller

Code

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;
}