You are here

public static function Views::pluginList in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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/src/Tests/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 374
Contains \Drupal\views\Views.

Class

Views
Static service container wrapper for views.

Namespace

Drupal\views

Code

public static function pluginList() {
  $plugin_data = static::getPluginDefinitions();
  $plugins = array();
  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] = array(
            'type' => $type,
            'title' => $info[$name]['title'],
            'provider' => $info[$name]['provider'],
            'views' => array(),
          );
        }

        // Add this view to the list for this plugin.
        $plugins[$key]['views'][$view
          ->id()] = $view
          ->id();
      }
    }
  }
  return $plugins;
}