You are here

public function ViewsUIController::reportPlugins in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views_ui/src/Controller/ViewsUIController.php \Drupal\views_ui\Controller\ViewsUIController::reportPlugins()
  2. 9 core/modules/views_ui/src/Controller/ViewsUIController.php \Drupal\views_ui\Controller\ViewsUIController::reportPlugins()

Lists all plugins and what enabled Views use them.

Return value

array The Views plugins report page.

1 string reference to 'ViewsUIController::reportPlugins'
views_ui.routing.yml in core/modules/views_ui/views_ui.routing.yml
core/modules/views_ui/views_ui.routing.yml

File

core/modules/views_ui/src/Controller/ViewsUIController.php, line 119

Class

ViewsUIController
Returns responses for Views UI routes.

Namespace

Drupal\views_ui\Controller

Code

public function reportPlugins() {
  $rows = Views::pluginList();
  foreach ($rows as &$row) {
    $views = [];

    // Link each view name to the view itself.
    foreach ($row['views'] as $view) {
      $views[] = Link::fromTextAndUrl($view, new Url('entity.view.edit_form', [
        'view' => $view,
      ]))
        ->toString();
    }
    unset($row['views']);
    $row['views']['data'] = [
      '#theme' => 'item_list',
      '#items' => $views,
      '#context' => [
        'list_style' => 'comma-list',
      ],
    ];
  }

  // Sort rows by field name.
  ksort($rows);
  return [
    '#type' => 'table',
    '#header' => [
      t('Type'),
      t('Name'),
      t('Provided by'),
      t('Used in'),
    ],
    '#rows' => $rows,
    '#empty' => t('There are no enabled views.'),
  ];
}