function Views::pluginList

Same name in other branches
  1. 9 core/modules/views/src/Views.php \Drupal\views\Views::pluginList()
  2. 10 core/modules/views/src/Views.php \Drupal\views\Views::pluginList()
  3. 11.x core/modules/views/src/Views.php \Drupal\views\Views::pluginList()

Returns a list of plugins and metadata about them.

Return value

array An array keyed by PLUGIN_TYPE:PLUGIN_NAME, like 'display:page' or 'pager:full', containing an array with the following keys:

  • title: The plugin's title.
  • type: The plugin type.
  • module: The module providing the plugin.
  • views: An array of enabled Views that are currently using this plugin, keyed by machine name.
2 calls to Views::pluginList()
ModuleTest::testViewsPluginList in core/modules/views/tests/src/Kernel/ModuleTest.php
Tests the \Drupal\views\Views::pluginList() method.
ViewsUIController::reportPlugins in core/modules/views_ui/src/Controller/ViewsUIController.php
Lists all plugins and what enabled Views use them.

File

core/modules/views/src/Views.php, line 371

Class

Views
Static service container wrapper for views.

Namespace

Drupal\views

Code

public static function pluginList() {
    $plugin_data = static::getPluginDefinitions();
    $plugins = [];
    foreach (static::getEnabledViews() as $view) {
        foreach ($view->get('display') as $display) {
            foreach ($plugin_data as $type => $info) {
                if ($type == 'display' && isset($display['display_plugin'])) {
                    $name = $display['display_plugin'];
                }
                elseif (isset($display['display_options']["{$type}_plugin"])) {
                    $name = $display['display_options']["{$type}_plugin"];
                }
                elseif (isset($display['display_options'][$type]['type'])) {
                    $name = $display['display_options'][$type]['type'];
                }
                else {
                    continue;
                }
                // Key first by the plugin type, then the name.
                $key = $type . ':' . $name;
                // Add info for this plugin.
                if (!isset($plugins[$key])) {
                    $plugins[$key] = [
                        'type' => $type,
                        'title' => $info[$name]['title'],
                        'provider' => $info[$name]['provider'],
                        'views' => [],
                    ];
                }
                // Add this view to the list for this plugin.
                $plugins[$key]['views'][$view->id()] = $view->id();
            }
        }
    }
    return $plugins;
}

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