Fetch a list of all base tables available
$type: Either 'display', 'style' or 'row'
$key: For style plugins, this is an optional type to restrict to. May be 'normal', 'summary', 'feed' or others based on the neds of the display.
$base: An array of possible base tables.
A keyed array of in the form of 'base_table' => 'Description'.
function views_fetch_plugin_names($type, $key = NULL, $base = array()) {
$definitions = drupal_container()
->get("plugin.manager.views.{$type}")
->getDefinitions();
$plugins = array();
foreach ($definitions as $id => $plugin) {
// Skip plugins that don't conform to our key.
if ($key && (empty($plugin['type']) || $plugin['type'] != $key)) {
continue;
}
// @todo While Views is providing on behalf of core modules, check to see
// if they are enabled or not.
if (isset($plugin['module']) && !module_exists($plugin['module'])) {
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;
}
// fall-through
return array();
}