public function Panelizer::setDisplayStaticContexts in Panelizer 8.5
Same name and namespace in other branches
- 8.3 src/Panelizer.php \Drupal\panelizer\Panelizer::setDisplayStaticContexts()
- 8.4 src/Panelizer.php \Drupal\panelizer\Panelizer::setDisplayStaticContexts()
Overrides PanelizerInterface::setDisplayStaticContexts
File
- src/
Panelizer.php, line 436
Class
- Panelizer
- The Panelizer service.
Namespace
Drupal\panelizerCode
public function setDisplayStaticContexts($name, $entity_type_id, $bundle, $view_mode, $contexts) {
$display = $this
->getEntityViewDisplay($entity_type_id, $bundle, $view_mode);
if (!$display) {
throw new PanelizerException("Unable to find display for given entity type, bundle and view mode");
}
// Set this Panels display's static contexts.
$panels_displays = $display
->getThirdPartySetting('panelizer', 'displays', []);
$panels_displays[$name]['static_context'] = $contexts;
$display
->setThirdPartySetting('panelizer', 'displays', $panels_displays);
$display
->save();
}