You are here

public function Ds::loadInstances in Bootstrap Layouts 8.5

Same name and namespace in other branches
  1. 8.4 src/Plugin/BootstrapLayouts/Ds.php \Drupal\bootstrap_layouts\Plugin\BootstrapLayouts\Ds::loadInstances()

Loads layout instances.

Parameters

string[]|int[] $ids: Optional. An array of identifiers to load. If no identifiers are specified, then all available instances will be loaded.

Return value

\Drupal\bootstrap_layouts\BootstrapLayout[] An associative array of BootstrapLayout instances, keyed by identifier.

Overrides BootstrapLayoutsHandlerInterface::loadInstances

File

src/Plugin/BootstrapLayouts/Ds.php, line 18

Class

Ds
Handles Display Suite specific layout implementations.

Namespace

Drupal\bootstrap_layouts\Plugin\BootstrapLayouts

Code

public function loadInstances(array $entity_ids = NULL) {
  $layouts = [];

  /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */
  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;
}