You are here

function panelizer_panelizer_task_get_addressable in Panelizer 7.2

Same name and namespace in other branches
  1. 7.3 plugins/task_handlers/panelizer_node.inc \panelizer_panelizer_task_get_addressable()
1 string reference to 'panelizer_panelizer_task_get_addressable'
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 267
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_get_addressable($task, $subtask_name, $handler, $address, $contexts, $arguments, $type) {
  ctools_include('plugins', 'panels');
  if (empty($contexts)) {
    return;
  }
  $context = _panelizer_panelizer_task_get_context($handler, $contexts);
  if (empty($context->data)) {
    return;
  }

  // Extract the entity from the context so we can load the panelizer.
  $entity =& $context->data;
  if (empty($entity->panelizer) || empty($entity->panelizer->display)) {
    return;
  }

  // Load the display.
  $display = $entity->panelizer->display;

  // Load the panelizer info.
  $panelizer = $entity->panelizer;

  // One of these two will always be set.
  $entity_type = !empty($panelizer->entity_type) ? $panelizer->entity_type : $panelizer->panelizer_type;
  $handler = panelizer_entity_plugin_get_handler($entity_type);
  if (!$handler) {
    return;
  }
  list($entity_id, $revision_id, $bundle) = entity_extract_ids($entity_type, $entity);
  $display->context = $handler
    ->get_contexts($panelizer, $entity);
  $display->args = $arguments;
  $display->css_id = $panelizer->css_id;
  $display->cache_key = implode(':', array(
    'panelizer',
    $entity_type,
    $entity_id,
  ));
  $renderer = panels_get_renderer($panelizer->pipeline, $display);
  $renderer
    ->prepare();
  $pid = array_shift($address);
  if (!empty($renderer->prepared['panes'][$pid])) {
    if ($type == 'content') {
      return $renderer
        ->render_pane($renderer->prepared['panes'][$pid]);
    }
    elseif ($type == 'pane') {
      return $renderer->prepared['panes'][$pid];
    }
  }
}