You are here

function panelizer_panelizer_task_test in Panelizer 7.3

Same name and namespace in other branches
  1. 6 plugins/task_handlers/panelizer_node.inc \panelizer_panelizer_task_test()
  2. 7 plugins/task_handlers/panelizer_node.inc \panelizer_panelizer_task_test()
  3. 7.2 plugins/task_handlers/panelizer_node.inc \panelizer_panelizer_task_test()

Determine if the panelizer task handler should fire.

This returns true if the configured entity is panelized and has a display.

1 string reference to 'panelizer_panelizer_task_test'
panelizer_node.inc in plugins/task_handlers/panelizer_node.inc
This is the task handler plugin to handle an entity view. NOTE: This is named panelizer_node for historical reasons. It is too much of a pain to change the name of a task handler. This panelizes any entity not just a node.

File

plugins/task_handlers/panelizer_node.inc, line 325
This is the task handler plugin to handle an entity view. NOTE: This is named panelizer_node for historical reasons. It is too much of a pain to change the name of a task handler. This panelizes any entity not just a node.

Code

function panelizer_panelizer_task_test($handler, $base_contexts) {
  ctools_include('context');
  if (!ctools_context_handler_select($handler, $base_contexts)) {
    return;
  }
  $context = _panelizer_panelizer_task_get_context($handler, $base_contexts);
  if (empty($context->data)) {
    return;
  }
  $entity =& $context->data;

  // Fail if there isn't a panelizer object on the entity.
  if (empty($entity->panelizer['page_manager']->display)) {
    return;
  }
  $panelizer = $entity->panelizer['page_manager'];
  $entity_type = !empty($panelizer->entity_type) ? $panelizer->entity_type : $panelizer->panelizer_type;
  $panelizer_handler = panelizer_entity_plugin_get_handler($entity_type);
  if (!$panelizer_handler) {
    return;
  }
  list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity);

  // Make sure the bundle + view mode is actually panelized!
  return $panelizer_handler
    ->is_panelized($bundle . '.page_manager');
}