You are here

protected function GridStackFormBase::getRegionSuggestions in GridStack 8.2

Returns the region suggestions.

1 call to GridStackFormBase::getRegionSuggestions()
GridStackFormBase::regionForm in modules/gridstack_ui/src/Form/GridStackFormBase.php
Returns the region form.

File

modules/gridstack_ui/src/Form/GridStackFormBase.php, line 461

Class

GridStackFormBase
Extends base form for gridstack instance configuration form.

Namespace

Drupal\gridstack_ui\Form

Code

protected function getRegionSuggestions() {
  if (!isset($this->regionSuggestions)) {
    $cid = 'gridstack_region_suggestions';
    if ($cache = $this->manager
      ->getCache()
      ->get($cid)) {
      $this->regionSuggestions = $cache->data;
    }
    else {
      $positions = [
        'ads',
        'aside',
        'content',
        'featured',
        'footer',
        'header',
        'hightlight',
        'hotdamn',
        'main',
        'meta',
        'preface',
        'postscript',
        'sidebar',
        'spotlight',
        'widget',
      ];
      $sequences = [
        'first',
        'second',
        'third',
        'fourth',
        'fifth',
        'last',
      ];
      $edges = [
        'top',
        'middle',
        'bottom',
      ];
      $sub_positions = [
        'top_first',
        'top_second',
        'top_third',
        'top_fourth',
        'top_fifth',
        'top_last',
        'middle_first',
        'middle_second',
        'middle_third',
        'middle_fourth',
        'middle_fifth',
        'middle_last',
        'bottom_first',
        'bottom_second',
        'bottom_third',
        'bottom_fourth',
        'bottom_fifth',
        'bottom_last',
      ];
      $lasts = [
        'last_first',
        'last_second',
        'last_third',
        'last_fourth',
        'last_fifth',
        'last_last',
      ];
      $contents = [
        'bg',
        'carousel',
        'chart',
        'currency',
        'donation',
        'news',
        'slideshow',
        'time',
        'weather',
      ];
      $minimals = [
        'overlay',
      ];
      $regions = [];
      foreach ($positions as $region) {
        $regions[$region] = $region;
        foreach ($sequences as $position) {
          $regions[$region . '_' . $position] = $region . '_' . $position;
        }
        foreach ($edges as $position) {
          $regions[$region . '_' . $position] = $region . '_' . $position;
        }
        foreach ($sub_positions as $position) {
          $regions[$region . '_' . $position] = $region . '_' . $position;
        }
        foreach ($lasts as $position) {
          $regions[$region . '_' . $position] = $region . '_' . $position;
        }
      }
      foreach ($contents as $content) {
        $regions[$content] = $content;
      }
      foreach ($minimals as $region) {
        $regions[$region] = $region;
        foreach ($sequences as $position) {
          $regions[$region . '_' . $position] = $region . '_' . $position;
        }
        foreach ($edges as $position) {
          $regions[$region . '_' . $position] = $region . '_' . $position;
        }
      }
      $this->manager
        ->getModuleHandler()
        ->alter('gridstack_region_suggestions', $regions);
      $count = count($regions);
      $tags = Cache::buildTags($cid, [
        'count:' . $count,
      ]);
      $this->manager
        ->getCache()
        ->set($cid, $regions, Cache::PERMANENT, $tags);
      $this->regionSuggestions = $regions;
    }
  }
  return $this->regionSuggestions;
}