function Views::fetchPluginNames

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

Fetches a list of all base tables available

Parameters

string $type: Either 'display', 'style' or 'row'.

string $key: For style plugins, this is an optional type to restrict to. May be 'normal', 'summary', 'feed' or others based on the needs of the display.

array $base: An array of possible base tables.

Return value

A keyed array of in the form of 'base_table' => 'Description'.

8 calls to Views::fetchPluginNames()
AdvancedSettingsForm::buildForm in core/modules/views_ui/src/Form/AdvancedSettingsForm.php
Form constructor.
DisplayPluginBase::buildOptionsForm in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Provide a form to edit options for this plugin.
Feed::newDisplay in core/modules/views/src/Plugin/views/display/Feed.php
Reacts on adding a display.
ModuleTest::testViewsFetchPluginNames in core/modules/views/tests/src/Kernel/ModuleTest.php
Tests the \Drupal\views\Views::fetchPluginNames() method.
ViewEditForm::getDisplayDetails in core/modules/views_ui/src/ViewEditForm.php
Helper function to get the display details section of the edit UI.

... See full list

File

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

Class

Views
Static service container wrapper for views.

Namespace

Drupal\views

Code

public static function fetchPluginNames($type, $key = NULL, array $base = []) {
    $definitions = static::pluginManager($type)->getDefinitions();
    $plugins = [];
    foreach ($definitions as $id => $plugin) {
        // Skip plugins that don't conform to our key, if they have one.
        if ($key && isset($plugin['display_types']) && !in_array($key, $plugin['display_types'])) {
            continue;
        }
        if (empty($plugin['no_ui']) && (empty($base) || empty($plugin['base']) || array_intersect($base, $plugin['base']))) {
            $plugins[$id] = $plugin['title'];
        }
    }
    if (!empty($plugins)) {
        asort($plugins);
        return $plugins;
    }
    return $plugins;
}

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