You are here

public function SlickAdmin::getOptionsetsByGroupOptions in Slick Carousel 8.2

Same name and namespace in other branches
  1. 8 src/Form/SlickAdmin.php \Drupal\slick\Form\SlickAdmin::getOptionsetsByGroupOptions()
  2. 7.3 src/Form/SlickAdmin.php \Drupal\slick\Form\SlickAdmin::getOptionsetsByGroupOptions()

Returns available slick optionsets by group.

2 calls to SlickAdmin::getOptionsetsByGroupOptions()
SlickAdmin::buildSettingsForm in src/Form/SlickAdmin.php
Returns the main form elements.
SlickAdmin::openingForm in src/Form/SlickAdmin.php
Returns the opening form elements.

File

src/Form/SlickAdmin.php, line 399

Class

SlickAdmin
Provides resusable admin functions, or form elements.

Namespace

Drupal\slick\Form

Code

public function getOptionsetsByGroupOptions($group = '') {
  $optionsets = $groups = $ungroups = [];
  $slicks = $this->manager
    ->entityLoadMultiple('slick');
  foreach ($slicks as $slick) {
    $name = Html::escape($slick
      ->label());
    $id = $slick
      ->id();
    $current_group = $slick
      ->getGroup();
    if (!empty($group)) {
      if ($current_group) {
        if ($current_group != $group) {
          continue;
        }
        $groups[$id] = $name;
      }
      else {
        $ungroups[$id] = $name;
      }
    }
    $optionsets[$id] = $name;
  }
  return $group ? array_merge($ungroups, $groups) : $optionsets;
}