1 utility.inc views_discover_plugins()

Builds and return a list of all plugins available in the system.

Return value

Nested array of plugins, grouped by type.

File

core/modules/views/includes/utility.inc, line 451
Utility functions for assembling Views queries.

Code

function views_discover_plugins() {
  $cache = array('display' => array(), 'style' => array(), 'row' => array(), 'argument default' => array(), 'argument validator' => array(), 'access' => array(), 'cache' => array(), 'exposed_form' => array());
  // Get plugins from all mdoules.
  foreach (module_implements('views_plugins') as $module) {
    $function = $module . '_views_plugins';
    $result = $function();
    if (!is_array($result)) {
      continue;
    }

    // Setup automatic path/file finding for theme registration
    $module_dir = isset($result['module']) ? $result['module'] : $module;
    // Assume the plugin path includes a 'plugins' directory.
    $path = backdrop_get_path('module', $module_dir) . '/plugins';
    // Assume the theme path includes a 'templates' directory.
    $theme_path = backdrop_get_path('module', $module_dir) . '/templates';
    // Assume the *.views.inc file for theme implementations.
    $theme_file = "$module.views.inc";

    // Add some special casing for the views module itself.
    if ($module_dir == 'views') {
      $theme_file = 'views.theme.inc';
    }

    foreach ($result as $type => $info) {
      if ($type == 'module') {
        continue;
      }
      foreach ($info as $plugin => $def) {
        $def['module'] = $module_dir;
        if (!isset($def['theme path'])) {
          $def['theme path'] = $theme_path;
        }
        if (!isset($def['theme file'])) {
          $def['theme file'] = $theme_file;
        }
        if (!isset($def['path'])) {
          $def['path'] = $path;
        }
        if (!isset($def['file'])) {
          $def['file'] = $def['handler'] . '.inc';
        }
        if (!isset($def['parent'])) {
          $def['parent'] = 'parent';
        }
        // Set the internal name to be able to read it out later.
        $def['name'] = $plugin;

        // merge the new data in
        $cache[$type][$plugin] = $def;
      }
    }
  }

  // Let other modules modify the plugins.
  backdrop_alter('views_plugins', $cache);
  return $cache;
}