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

Get all contexts required or configured for this menu path.

return LayoutContext[]

File

core/modules/layout/includes/layout_menu_item.class.inc, line 231
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)) {
    // 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);
        $contexts[$position] = layout_create_context($argument_config['plugin'], $context_config);
      }
    }

    // Add on the current user context, which is always available.
    $contexts['current_user'] = layout_create_context('user', array(
      'name' => 'current_user',
      'label' => t('Current user'),
      'locked' => TRUE,
    ));
    $contexts['current_user']->setData($GLOBALS['user']);

    $this->contexts = $contexts;
  }
  return $this->contexts;
}