1 layout.class.inc Layout::getContexts()

Return all contexts (from both the layout and menu item) for this Layout.

return LayoutContext[]

File

core/modules/layout/includes/layout.class.inc, line 736
Class for loading, modifying, and executing a layout.

Class

Layout
@file Class for loading, modifying, and executing a layout.

Code

function getContexts() {
  if (is_null($this->contexts)) {
    if ($this->menu_item) {
      $this->contexts = $this->menu_item->getContexts();
    }
    elseif ($this->path) {
      $this->contexts = layout_context_required_by_path($this->path);
    }
    else {
      $this->contexts = array();
    }
  }

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

  // Add on the overrides path context, which is always available.
  if (empty($this->menu_item) && !isset($this->contexts['overrides_path'])) {
    $this->contexts['overrides_path'] = layout_create_context('overrides_path', array(
      'name' => 'overrides_path',
      'locked' => TRUE,
    ));
  }

  return $this->contexts;
}