3 namespace Drupal\field_ui\Controller;
5 use Drupal\Core\Controller\ControllerBase;
9 * Provides methods for entity display mode routes.
11 class EntityDisplayModeController extends ControllerBase {
14 * Provides a list of eligible entity types for adding view modes.
17 * A list of entity types to add a view mode for.
19 public function viewModeTypeSelection() {
21 foreach ($this->entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
22 if ($entity_type->get('field_ui_base_route') && $entity_type->hasViewBuilderClass()) {
23 $entity_types[$entity_type_id] = [
24 'title' => $entity_type->getLabel(),
25 'url' => Url::fromRoute('entity.entity_view_mode.add_form', ['entity_type_id' => $entity_type_id]),
26 'localized_options' => [],
31 '#theme' => 'admin_block_content',
32 '#content' => $entity_types,
37 * Provides a list of eligible entity types for adding form modes.
40 * A list of entity types to add a form mode for.
42 public function formModeTypeSelection() {
44 foreach ($this->entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
45 if ($entity_type->get('field_ui_base_route') && $entity_type->hasFormClasses()) {
46 $entity_types[$entity_type_id] = [
47 'title' => $entity_type->getLabel(),
48 'url' => Url::fromRoute('entity.entity_form_mode.add_form', ['entity_type_id' => $entity_type_id]),
49 'localized_options' => [],
54 '#theme' => 'admin_block_content',
55 '#content' => $entity_types,