public function Ds::saveInstances in Bootstrap Layouts 8.5
Same name and namespace in other branches
- 8.4 src/Plugin/BootstrapLayouts/Ds.php \Drupal\bootstrap_layouts\Plugin\BootstrapLayouts\Ds::saveInstances()
Saves layout instances.
Parameters
\Drupal\bootstrap_layouts\BootstrapLayout[] $layouts: An associative array of BootstrapLayout instances, keyed by identifier.
Throws
\Drupal\Core\Entity\EntityStorageException In case of failures an exception is thrown.
Overrides BootstrapLayoutsHandlerInterface::saveInstances
File
- src/
Plugin/ BootstrapLayouts/ Ds.php, line 36
Class
- Ds
- Handles Display Suite specific layout implementations.
Namespace
Drupal\bootstrap_layouts\Plugin\BootstrapLayoutsCode
public function saveInstances(array $layouts = []) {
$displays = EntityViewDisplay::loadMultiple(array_keys($layouts));
/** @var \Drupal\bootstrap_layouts\BootstrapLayout[] $layouts */
foreach ($layouts as $entity_id => $layout) {
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */
$display = $displays[$entity_id];
$info = $display
->getThirdPartySettings('ds');
$info['layout']['id'] = $layout
->getId();
$info['regions'] = $layout
->getRegions();
$info['layout']['settings'] = $layout
->getSettings();
$info['layout']['path'] = $layout
->getPath();
// Unfortunately, there is no "setThirdPartySettings" method, so each
// property must be iterated over manually, set and then saved.
foreach ($info as $key => $value) {
$display
->setThirdPartySetting('ds', $key, $value);
}
$display
->save();
}
}