You are here

public function SlickManager::getOptionsetByGroupOptions in Slick Carousel 7.3

Returns available slick optionsets by collection for select options.

File

src/SlickManager.php, line 209

Class

SlickManager
Implements SlickManagerInterface.

Namespace

Drupal\slick

Code

public function getOptionsetByGroupOptions($group = '') {
  if (!isset($this->optionsetByGroup[$group])) {
    $optionsets = $collected = $uncollected = [];
    $slicks = Slick::loadMultiple();
    foreach ($slicks as $slick) {
      $name = check_plain($slick->label);
      $id = $slick->name;
      $current_collection = $slick->collection;
      if (!empty($group)) {
        if ($current_collection) {
          if ($current_collection != $group) {
            continue;
          }
          $collected[$id] = $name;
        }
        else {
          $uncollected[$id] = $name;
        }
      }
      $optionsets[$id] = $name;
    }
    $this->optionsetByGroup[$group] = $group ? array_merge($uncollected, $collected) : $optionsets;
  }
  return $this->optionsetByGroup[$group];
}