You are here

public function SlickSkinManager::getSkinsByGroup in Slick Carousel 8.2

Returns available slick skins by group.

2 calls to SlickSkinManager::getSkinsByGroup()
SlickSkinManager::attachSkin in src/SlickSkinManager.php
Provides skins only if required.
SlickSkinManager::libraryInfoBuild in src/SlickSkinManager.php
Implements hook_library_info_build().

File

src/SlickSkinManager.php, line 187

Class

SlickSkinManager
Provides Slick skin manager.

Namespace

Drupal\slick

Code

public function getSkinsByGroup($group = '', $option = FALSE) {
  if (!isset($this->skinsByGroup[$group])) {
    $skins = $groups = $ungroups = [];
    $nav_skins = in_array($group, [
      'arrows',
      'dots',
    ]);
    $defined_skins = $nav_skins ? $this
      ->getSkins()[$group] : $this
      ->getSkins()['skins'];
    foreach ($defined_skins as $skin => $properties) {
      $item = $option ? strip_tags($properties['name']) : $properties;
      if (!empty($group)) {
        if (isset($properties['group'])) {
          if ($properties['group'] != $group) {
            continue;
          }
          $groups[$skin] = $item;
        }
        elseif (!$nav_skins) {
          $ungroups[$skin] = $item;
        }
      }
      $skins[$skin] = $item;
    }
    $this->skinsByGroup[$group] = $group ? array_merge($ungroups, $groups) : $skins;
  }
  return $this->skinsByGroup[$group];
}