function ViewsUIController::reportPlugins

Same name in other branches
  1. 8.9.x core/modules/views_ui/src/Controller/ViewsUIController.php \Drupal\views_ui\Controller\ViewsUIController::reportPlugins()
  2. 10 core/modules/views_ui/src/Controller/ViewsUIController.php \Drupal\views_ui\Controller\ViewsUIController::reportPlugins()
  3. 11.x 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.'),
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.