You are here

public function PanelizerFieldPanelsStorage::load in Panelizer 8.3

Same name and namespace in other branches
  1. 8.5 src/Plugin/PanelsStorage/PanelizerFieldPanelsStorage.php \Drupal\panelizer\Plugin\PanelsStorage\PanelizerFieldPanelsStorage::load()
  2. 8.4 src/Plugin/PanelsStorage/PanelizerFieldPanelsStorage.php \Drupal\panelizer\Plugin\PanelsStorage\PanelizerFieldPanelsStorage::load()

File

src/Plugin/PanelsStorage/PanelizerFieldPanelsStorage.php, line 111

Class

PanelizerFieldPanelsStorage
Panels storage service that stores Panels displays in the Panelizer field.

Namespace

Drupal\panelizer\Plugin\PanelsStorage

Code

public function load($id) {
  if ($entity = $this
    ->loadEntity($id)) {
    list($entity_type_id, , $view_mode) = explode(':', $id);
    if ($panels_display = $this->panelizer
      ->getPanelsDisplay($entity, $view_mode)) {

      // Set the entity as a context on the Panels display.
      $contexts = [
        '@panelizer.entity_context:entity' => $this
          ->getEntityContext($entity_type_id, $entity),
      ];
      $panels_display
        ->setContexts($contexts);
      return $panels_display;
    }
  }
}