You are here

function panelizer_entity_plugin_switcher_page in Panelizer 7.3

Same name and namespace in other branches
  1. 7.2 panelizer.module \panelizer_entity_plugin_switcher_page()

Page callback for entity menu callbacks.

This function is to be used as a menu callback for menu items that are to be handled by a method on the handler object. It loads the object defined in the plugin and hands it off to a method based upon the name of the operation in use.

For example, if the 'op' is 'revision' then the callback method will be 'page_revisions', with all of the arguments *except* the $op and the plugin name.

1 string reference to 'panelizer_entity_plugin_switcher_page'
PanelizerEntityDefault::hook_menu in plugins/entity/PanelizerEntityDefault.class.php
Implements a delegated hook_menu.

File

./panelizer.module, line 783
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_switcher_page($entity_type, $op) {
  $args = func_get_args();

  // Load the $plugin information.
  if ($handler = panelizer_entity_plugin_get_handler($entity_type)) {

    // Replace the first two arguments.
    $args[0] = !empty($_REQUEST['js']);
    $args[1] = $_POST;
    if (empty($args[3])) {
      $args[3] = 'page_manager';
    }
    $method = 'page_' . $op;
    if (method_exists($handler, $method)) {
      return call_user_func_array(array(
        $handler,
        $method,
      ), $args);
    }

    // Check to see if this is an operation from panelizer_operations with a
    // callback instead.
    $operations = panelizer_operations();
    if (isset($operations[$op]) && isset($operations[$op]['entity callback']) && function_exists($operations[$op]['entity callback'])) {
      array_unshift($args, $handler);
      return call_user_func_array($operations[$op]['entity callback'], $args);
    }
  }
  else {
    return t('Configuration error. No handler found.');
  }
}