You are here

function panelizer_entity_plugin_switcher_page in Panelizer 7.2

Same name and namespace in other branches
  1. 7.3 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 447
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();
  $js = !empty($_REQUEST['js']);

  // Load the $plugin information
  if ($handler = panelizer_entity_plugin_get_handler($entity_type)) {
    $method = 'page_' . $op;
    if (method_exists($handler, $method)) {

      // replace the first two arguments:
      $args[0] = $js;
      $args[1] = $_POST;
      return call_user_func_array(array(
        $handler,
        $method,
      ), $args);
    }
  }
  else {
    return t('Configuration error. No handler found.');
  }
}