You are here

protected function ViewsLayoutStyle::setRegions in Views Layout 8

1 call to ViewsLayoutStyle::setRegions()
ViewsLayoutStyle::__construct in src/Plugin/views/style/ViewsLayoutStyle.php
Constructs a PluginBase object.

File

src/Plugin/views/style/ViewsLayoutStyle.php, line 99

Class

ViewsLayoutStyle
Style plugin for the timeline view.

Namespace

Drupal\views_layout\Plugin\views\style

Code

protected function setRegions() {
  $layouts = [];
  $regions = [];
  $definitions = $this->layoutPluginManager
    ->getDefinitions('layout_builder');
  foreach ($definitions as $plugin_id => $definition) {
    $icon_values = $definition
      ->getIcon(45, 60, 1, 3);
    $icon = \Drupal::service('renderer')
      ->renderPlain($icon_values);
    $layouts[$plugin_id] = [
      'icon' => $icon,
      'name' => $definition
        ->getLabel(),
    ];
    $regions[$plugin_id]['label'] = $this
      ->t(':name', [
      ':name' => $definition
        ->getLabel(),
    ]);
    $regions[$plugin_id]['icon'] = $icon;
    foreach ($definition
      ->getRegionLabels() as $region_id => $label) {
      $regions[$plugin_id]['regions'][$region_id] = $label;
    }
  }
  $this->layouts = $layouts;
  $this->regions = $regions;
}