You are here

function panelizer_entity_plugin_get_handler in Panelizer 7.2

Same name and namespace in other branches
  1. 7.3 panelizer.module \panelizer_entity_plugin_get_handler()

Get the class to handle custom code for a given entity type plugin.

If a plugin does not define a class at all, then the default class

Return value

Either the instantiated handler or FALSE if one could not be had.

38 calls to panelizer_entity_plugin_get_handler()
panelizer_administer_entity_bundle in ./panelizer.module
Access callback to see if a user can administer a particular bundle.
panelizer_administer_panelizer_default in ./panelizer.module
Access callback to see if a user can administer a particular panelizer default.
panelizer_allowed_content_page in includes/admin.inc
Page to configure what content is available for a given node type.
panelizer_context_cache_get in ./panelizer.module
Fetch the panelizer object from the object cache.
panelizer_ctools_access_clear in ./panelizer.module
Implement CTools access form caching callback: get.

... See full list

File

./panelizer.module, line 375
The Panelizer module attaches panels to entities, providing default panels and allowing each panel to be configured independently by privileged users.

Code

function panelizer_entity_plugin_get_handler($plugin) {

  // The default plugin handler is abstract and cannot be loaded.
  if ($plugin == 'default') {
    return;
  }
  $cache =& drupal_static(__FUNCTION__, array());

  // If a string was passed, turn it into a plugin.
  if (is_string($plugin)) {
    $plugin = panelizer_get_entity_plugin($plugin);
    if (!$plugin) {
      return FALSE;
    }
  }

  // Get the class name from the 'handler' property if we have not already
  // cached a handler.
  if (is_object($plugin)) {
    vpr_trace();
    exit;
  }
  if (empty($cache[$plugin['name']]) && ($class = ctools_plugin_get_class($plugin, 'handler'))) {

    // @todo is there a good reason to use ->init instead of __construct?
    $cache[$plugin['name']] = new $class();
    $cache[$plugin['name']]
      ->init($plugin);
  }
  return !empty($cache[$plugin['name']]) ? $cache[$plugin['name']] : FALSE;
}