You are here

function panels_breadcrumbs_panelizer_pre_render_alter in Panels Breadcrumbs 7.2

Implements hook_panelizer_pre_render_alter().

Set the breadcrumb for the panelized entity.

File

./panels_breadcrumbs.module, line 522
Main file for panels breadcrumbs module.

Code

function panels_breadcrumbs_panelizer_pre_render_alter(&$panelizer, &$display, $entity) {
  if (isset($panelizer->entity_type)) {
    $entity_type = $panelizer->entity_type;
  }
  elseif (isset($panelizer->panelizer_type)) {
    $entity_type = $panelizer->panelizer_type;
  }
  else {
    return;
  }
  $panelizer_entity_plugin = panelizer_entity_plugin_get_handler($entity_type);
  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
  $default = $panelizer_entity_plugin
    ->get_default_panelizer_object($bundle, $panelizer->name);

  // Check panelizers breadcrumb configuration.
  if (!empty($default->extra['panels_breadcrumbs_state']) || !empty($panelizer->extra['panels_breadcrumbs_state'])) {

    // Check panelizers overridden configuration state.
    if (isset($panelizer->extra['panels_breadcrumbs_state']) && $panelizer->extra['panels_breadcrumbs_state']) {
      $conf = $panelizer->extra;
    }
    elseif (isset($default->extra['panels_breadcrumbs_state']) && $default->extra['panels_breadcrumbs_state']) {
      $conf = $default->extra;
    }
    else {
      return;
    }
  }
  if (!empty($panelizer->extra['panels_breadcrumbs_state'])) {
    panels_breadcrumbs_build_breadcrumb($conf, $display->context, TRUE);

    // Store the panelizer breadcrumb configuration.
    panels_breadcrumbs_get_panelizer_breadcrumb_conf($conf);
  }
}