You are here

public function BootstrapLayoutDeriver::getDerivativeDefinitions in Bootstrap Layout Builder 2.x

Same name and namespace in other branches
  1. 1.x src/Plugin/Deriver/BootstrapLayoutDeriver.php \Drupal\bootstrap_layout_builder\Plugin\Deriver\BootstrapLayoutDeriver::getDerivativeDefinitions()

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Deriver/BootstrapLayoutDeriver.php, line 49

Class

BootstrapLayoutDeriver
Makes a bootstrap layout for each layout config entity.

Namespace

Drupal\bootstrap_layout_builder\Plugin\Deriver

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $layouts = $this->entityTypeManager
    ->getStorage('blb_layout')
    ->getQuery()
    ->sort('number_of_columns', 'ASC')
    ->execute();
  if ($layouts) {
    foreach ($layouts as $layout_id) {
      $layout = $this->entityTypeManager
        ->getStorage('blb_layout')
        ->load($layout_id);
      $this->derivatives[$layout
        ->id()] = new LayoutDefinition([
        'class' => BootstrapLayout::class,
        'label' => $layout
          ->label(),
        'id' => $layout
          ->id(),
        'category' => 'Bootstrap',
        'regions' => $this
          ->getRegions($layout
          ->getNumberOfColumns()),
        'theme_hook' => 'blb_section',
        'icon_map' => $this
          ->getIconMap($layout
          ->getNumberOfColumns()),
      ]);
    }
  }
  return $this->derivatives;
}