You are here

public function EntityTypeInfoController::entityTypeList in Devel 8.3

Same name and namespace in other branches
  1. 8 src/Controller/EntityTypeInfoController.php \Drupal\devel\Controller\EntityTypeInfoController::entityTypeList()
  2. 8.2 src/Controller/EntityTypeInfoController.php \Drupal\devel\Controller\EntityTypeInfoController::entityTypeList()
  3. 4.x src/Controller/EntityTypeInfoController.php \Drupal\devel\Controller\EntityTypeInfoController::entityTypeList()

Builds the entity types overview page.

Return value

array A render array as expected by the renderer.

1 string reference to 'EntityTypeInfoController::entityTypeList'
devel.routing.yml in ./devel.routing.yml
devel.routing.yml

File

src/Controller/EntityTypeInfoController.php, line 59

Class

EntityTypeInfoController
Provides route responses for the entity types info page.

Namespace

Drupal\devel\Controller

Code

public function entityTypeList() {
  $headers = [
    $this
      ->t('ID'),
    $this
      ->t('Name'),
    $this
      ->t('Provider'),
    $this
      ->t('Class'),
    $this
      ->t('Operations'),
  ];
  $rows = [];
  foreach ($this
    ->entityTypeManager()
    ->getDefinitions() as $entity_type_id => $entity_type) {
    $row['id'] = [
      'data' => $entity_type
        ->id(),
      'filter' => TRUE,
    ];
    $row['name'] = [
      'data' => $entity_type
        ->getLabel(),
      'filter' => TRUE,
    ];
    $row['provider'] = [
      'data' => $entity_type
        ->getProvider(),
      'filter' => TRUE,
    ];
    $row['class'] = [
      'data' => $entity_type
        ->getClass(),
      'filter' => TRUE,
    ];
    $row['operations']['data'] = [
      '#type' => 'operations',
      '#links' => [
        'devel' => [
          'title' => $this
            ->t('Devel'),
          'url' => Url::fromRoute('devel.entity_info_page.detail', [
            'entity_type_id' => $entity_type_id,
          ]),
          'attributes' => [
            'class' => [
              'use-ajax',
            ],
            'data-dialog-type' => 'modal',
            'data-dialog-options' => Json::encode([
              'width' => 700,
              'minHeight' => 500,
            ]),
          ],
        ],
        'fields' => [
          'title' => $this
            ->t('Fields'),
          'url' => Url::fromRoute('devel.entity_info_page.fields', [
            'entity_type_id' => $entity_type_id,
          ]),
          'attributes' => [
            'class' => [
              'use-ajax',
            ],
            'data-dialog-type' => 'modal',
            'data-dialog-options' => Json::encode([
              'width' => 700,
              'minHeight' => 500,
            ]),
          ],
        ],
      ],
    ];
    $rows[$entity_type_id] = $row;
  }
  ksort($rows);
  $output['entities'] = [
    '#type' => 'devel_table_filter',
    '#filter_label' => $this
      ->t('Search'),
    '#filter_placeholder' => $this
      ->t('Enter entity type id, provider or class'),
    '#filter_description' => $this
      ->t('Enter a part of the entity type id, provider or class to filter by.'),
    '#header' => $headers,
    '#rows' => $rows,
    '#empty' => $this
      ->t('No entity types found.'),
    '#sticky' => TRUE,
    '#attributes' => [
      'class' => [
        'devel-entity-type-list',
      ],
    ],
  ];
  return $output;
}