You are here

public static function Views::getPluginTypes in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/views/src/Views.php \Drupal\views\Views::getPluginTypes()

Returns a list of plugin types.

Parameters

string $type: (optional) filter the list of plugins by type. Available options are 'plugin' or 'handler'.

Return value

array An array of plugin types.

3 calls to Views::getPluginTypes()
DisplayPluginBase::calculateCacheMetadata in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Calculates the display's cache metadata by inspecting each handler/plugin.
DisplayPluginBase::getAllPlugins in core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
Gets all the plugins used by the display.
ViewExecutable::getPluginTypes in core/modules/views/src/ViewExecutable.php
Returns the valid types of plugins that can be used.

File

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

Class

Views
Static service container wrapper for views.

Namespace

Drupal\views

Code

public static function getPluginTypes($type = NULL) {
  if ($type === NULL) {
    return array_keys(static::$plugins);
  }
  if (!in_array($type, [
    'plugin',
    'handler',
  ])) {
    throw new \Exception('Invalid plugin type used. Valid types are "plugin" or "handler".');
  }
  return array_keys(array_filter(static::$plugins, function ($plugin_type) use ($type) {
    return $plugin_type == $type;
  }));
}