You are here

function panelizer_entity_plugin_get_handler in Panelizer 7.3

Same name and namespace in other branches
  1. 7.2 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.

56 calls to panelizer_entity_plugin_get_handler()
PanelizerSearchApiAlterCallback::alterItems in plugins/search_api/PanelizerSearchApiAlterCallback.class.php
Alter items before indexing.
PanelizerTestHelper::getDefaultPanelizerDisplay in tests/panelizer.helper.test
Get the default Panelizer display for a specific entity bundle.
PanelizerTestHelper::togglePanelizer in tests/panelizer.helper.test
Helper function to quickly enable or disable Panelizer for an entity type.
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 default.

... See full list

File

./panelizer.module, line 715
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 (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;
}