You are here

public function PageManagerPanelsStorage::save in Panels 8.4

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

Saves a Panels display.

Parameters

\Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant $panels_display: The Panels display to save. $panels_display->getStorageId() must return the display's id as known to this storage plugin.

Throws

\Exception If the storage information isn't set, or there is no such Panels display.

Overrides PanelsStorageInterface::save

File

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

Class

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

Namespace

Drupal\panels\Plugin\PanelsStorage

Code

public function save(PanelsDisplayVariant $panels_display) {
  $id = $panels_display
    ->getStorageId();
  if ($id && ($page_variant = $this
    ->loadPageVariant($id))) {
    $variant_plugin = $page_variant
      ->getVariantPlugin();
    if (!$variant_plugin instanceof PanelsDisplayVariant) {
      throw new \Exception("Page variant doesn't use a Panels display variant");
    }
    $variant_plugin
      ->setConfiguration($panels_display
      ->getConfiguration());
    $page_variant
      ->save();
  }
  else {
    throw new \Exception("Couldn't find page variant to store Panels display");
  }
}