Ds.php in Bootstrap Layouts 8.5
File
src/Plugin/BootstrapLayouts/Ds.php
View source
<?php
namespace Drupal\bootstrap_layouts\Plugin\BootstrapLayouts;
use Drupal\bootstrap_layouts\BootstrapLayout;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
class Ds extends BootstrapLayoutsHandlerBase {
public function loadInstances(array $entity_ids = NULL) {
$layouts = [];
foreach (EntityViewDisplay::loadMultiple($entity_ids) as $entity_id => $display) {
if (($info = $display
->getThirdPartySettings('ds')) && isset($info['layout']['id'])) {
$id = $info['layout']['id'];
$regions = $info['regions'];
$settings = $info['layout']['settings'];
$path = isset($info['layout']['path']) ? $info['layout']['path'] : '';
$layouts[$entity_id] = new BootstrapLayout($id, $regions, $settings, $path);
}
}
return $layouts;
}
public function saveInstances(array $layouts = []) {
$displays = EntityViewDisplay::loadMultiple(array_keys($layouts));
foreach ($layouts as $entity_id => $layout) {
$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();
foreach ($info as $key => $value) {
$display
->setThirdPartySetting('ds', $key, $value);
}
$display
->save();
}
}
}
Classes
Name |
Description |
Ds |
Handles Display Suite specific layout implementations. |