EntityDisplayModeController.php in Drupal 8
File
core/modules/field_ui/src/Controller/EntityDisplayModeController.php
View source
<?php
namespace Drupal\field_ui\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Url;
class EntityDisplayModeController extends ControllerBase {
public function viewModeTypeSelection() {
$entity_types = [];
foreach ($this
->entityTypeManager()
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type
->get('field_ui_base_route') && $entity_type
->hasViewBuilderClass()) {
$entity_types[$entity_type_id] = [
'title' => $entity_type
->getLabel(),
'url' => Url::fromRoute('entity.entity_view_mode.add_form', [
'entity_type_id' => $entity_type_id,
]),
'localized_options' => [],
];
}
}
return [
'#theme' => 'admin_block_content',
'#content' => $entity_types,
];
}
public function formModeTypeSelection() {
$entity_types = [];
foreach ($this
->entityTypeManager()
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type
->get('field_ui_base_route') && $entity_type
->hasFormClasses()) {
$entity_types[$entity_type_id] = [
'title' => $entity_type
->getLabel(),
'url' => Url::fromRoute('entity.entity_form_mode.add_form', [
'entity_type_id' => $entity_type_id,
]),
'localized_options' => [],
];
}
}
return [
'#theme' => 'admin_block_content',
'#content' => $entity_types,
];
}
}