You are here

public function DefaultPattern::getDefaultContexts in Panels 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/PanelsPattern/DefaultPattern.php \Drupal\panels\Plugin\PanelsPattern\DefaultPattern::getDefaultContexts()

Gets the array of default contexts for this panels pattern.

Parameters

\Drupal\user\SharedTempStoreFactory $tempstore: The tempstore factory object.

string $tempstore_id: The tempstore identifier.

string $machine_name: The tempstore key.

Return value

\Drupal\Core\Plugin\Context\ContextInterface[]

Overrides PanelsPatternInterface::getDefaultContexts

File

src/Plugin/PanelsPattern/DefaultPattern.php, line 69

Class

DefaultPattern
Plugin annotation @PanelsPattern("default");

Namespace

Drupal\panels\Plugin\PanelsPattern

Code

public function getDefaultContexts(SharedTempStoreFactory $tempstore, $tempstore_id, $machine_name) {
  $cached_values = $this
    ->getCachedValues($tempstore, $tempstore_id, $machine_name);

  // PageManager specific context loading.
  if (!empty($cached_values['page_variant'])) {

    /** @var \Drupal\page_manager\PageVariantInterface $page_variant */
    $page_variant = $cached_values['page_variant'];
    return $page_variant
      ->getContexts();
  }

  // General handling for contexts.
  return !empty($cached_values['contexts']) ? $this->contextMapper
    ->getContextValues($cached_values['contexts']) : [];
}