You are here

public function PageManagerPanelsStorage::load in Panels 8.4

Same name and namespace in other branches
  1. 8.3 src/Plugin/PanelsStorage/PageManagerPanelsStorage.php \Drupal\panels\Plugin\PanelsStorage\PageManagerPanelsStorage::load()

Loads a Panels display.

Parameters

string $id: The id for the Panels display within this storage plugin.

Return value

\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant|NULL The Panels display if one exists with this id; NULL otherwise.

Overrides PanelsStorageInterface::load

File

src/Plugin/PanelsStorage/PageManagerPanelsStorage.php, line 87

Class

PageManagerPanelsStorage
A Panels storage service that stores Panels displays in Page Manager.

Namespace

Drupal\panels\Plugin\PanelsStorage

Code

public function load($id) {
  if ($page_variant = $this
    ->loadPageVariant($id)) {
    $panels_display = $page_variant
      ->getVariantPlugin();

    // If this page variant doesn't have a Panels display on it, then we treat
    // it the same as if there was no such page variant.
    if (!$panels_display instanceof PanelsDisplayVariant) {
      return NULL;
    }

    // Pass down the contexts because the display has no other way to get them
    // from the variant.
    $panels_display
      ->setContexts($page_variant
      ->getContexts());
    return $panels_display;
  }
}