You are here

function panels_get_plugins in Panels 6.2

Same name and namespace in other branches
  1. 5.2 includes/plugins.inc \panels_get_plugins()

Fetch a group of plugins by name.

This function is the master static cache through which all calls to plugins pass; metadata about those plugins is all statically cached here.

Parameters

$plugin: This is the name of the plugin, and also the name of the directory.

$hook: This is the hook to call to get the info for the plugin.

Return value

An array of information arrays about the plugins received.

17 calls to panels_get_plugins()
panels_get_argument in includes/plugins.inc
Fetch metadata on a specific argument plugin.
panels_get_arguments in includes/plugins.inc
Fetch metadata for all argument plugins.
panels_get_cache in includes/plugins.inc
Fetch metadata on a specific caching plugin.
panels_get_caches in includes/plugins.inc
Fetch metadata for all context plugins.
panels_get_content_type in includes/plugins.inc
Fetch metadata on a specific content_type plugin.

... See full list

File

includes/plugins.inc, line 1529
plugins.inc

Code

function panels_get_plugins($plugin, $hook, $id = NULL) {
  static $plugins = array();
  static $all_hooks = array();
  static $all_files = array();

  // Always load all hooks if we need them.
  if (!isset($all_hooks[$plugin])) {
    $all_hooks[$plugin] = TRUE;
    $plugins[$plugin] = panels_load_hooks($hook);
  }

  // First, see if it's in our hooks before we even bother.
  if ($id && array_key_exists($id, $plugins[$plugin])) {
    return $plugins[$plugin][$id];
  }

  // Then see if we should load all files. We only do this if we
  // want a list of all plugins.
  if (!$id && empty($all_files[$plugin])) {
    $all_files[$plugin] = TRUE;
    $plugins[$plugin] = array_merge($plugins[$plugin], panels_load_includes($plugin, $hook));
  }

  // If no id was requested, we are finished here:
  if (!$id) {
    return $plugins[$plugin];
  }

  // Check to see if we need to look for the file
  if (!array_key_exists($id, $plugins[$plugin])) {
    $result = panels_load_includes($plugin, $hook, $id);

    // Set to either what was returned or NULL.
    $plugins[$plugin][$id] = isset($result[$id]) ? $result[$id] : NULL;
  }

  // At this point we should either have the plugin, or a NULL.
  return $plugins[$plugin][$id];
}