1 layout_menu_item.class.inc LayoutMenuItem::getContexts()

Get all contexts required or configured for this menu path.

Return value

LayoutContext[]:

File

core/modules/layout/includes/layout_menu_item.class.inc, line 243
Class for storing information about menu item entries.

Class

LayoutMenuItem
@file Class for storing information about menu item entries.

Code

function getContexts() {
  if (is_null($this->contexts)) {
    $this->contexts = array();
  }

  $this->resetContexts();

  // Required contexts are generated on-demand.
  $contexts = layout_context_required_by_path($this->path);
  $path_parts = explode('/', $this->path);

  // Add in configured arguments.
  foreach ($this->arguments as $position => $argument_config) {
    if (isset($path_parts[$position]) && $path_parts[$position] === '%') {
      $context_config = $argument_config + array(
        'required' => TRUE,
        'usageType' => LayoutContext::USAGE_TYPE_MENU,
      );
      $contexts[$position] = layout_create_context($argument_config['plugin'], $context_config);
    }
  }

  // Add on the current user context, which is always available.
  $contexts['current_user'] = layout_current_user_context();

  $this->contexts += $contexts;

  return $this->contexts;
}