You are here

function bean_fetch_plugin_info in Bean (for Drupal 7) 7

Fetch the widget plugin info

4 calls to bean_fetch_plugin_info()
bean_admin_ui_page_title in bean_admin_ui/bean_admin_ui.module
Page title for block types
bean_edit in includes/bean.pages.inc
Edit bean page callback
bean_load_plugin_class in ./bean.module
Load a widget class
bean_load_plugin_class_all in ./bean.module
Load all widget classes
1 string reference to 'bean_fetch_plugin_info'
bean_bean_cache_clear in ./bean.module
Implements hook_bean_cache_clear().

File

./bean.module, line 346
Block Entity

Code

function bean_fetch_plugin_info($plugin = NULL) {
  $plugins =& drupal_static(__FUNCTION__);
  ctools_include('plugins');
  if (empty($plugins)) {
    if (($cache = cache_get('bean_plugins')) && !empty($cache->data)) {
      $plugins = $cache->data;
    }
    else {
      $plugins = ctools_get_plugins('bean', 'types');

      // Only use modules with the same version.
      $allowed_modules = array_keys(ctools_plugin_api_info('bean', 'types', bean_min_version(), bean_current_version()));
      foreach ($plugins as $key => $plugin_value) {
        if (!in_array($plugin_value['module'], $allowed_modules) || $plugin_value['abstract']) {
          unset($plugins[$key]);
        }
      }
      cache_set('bean_plugins', $plugins);
    }
  }
  if (empty($plugin)) {
    return $plugins;
  }
  else {

    // Make sure the plugin is in the cache.
    if (!isset($plugins[$plugin])) {
      $plugin_info = ctools_get_plugins('bean', 'types', $plugin);
      if (empty($allowed_modules)) {
        $allowed_modules = array_keys(ctools_plugin_api_info('bean', 'types', bean_current_version(), bean_min_version()));
      }
      if (in_array($plugin_info['module'], $allowed_modules)) {
        $plugins[$plugin] = $plugin_info;
        cache_set('bean_plugins', $plugins);
      }
    }

    // If we still don't have the plugin then return NULL.
    if (empty($plugins[$plugin])) {
      return NULL;
    }
    return $plugins[$plugin];
  }
}