You are here

public function SlickManager::getSkinsByGroup in Slick Carousel 8

Same name and namespace in other branches
  1. 8.2 src/SlickManager.php \Drupal\slick\SlickManager::getSkinsByGroup()
  2. 7.3 src/SlickManager.php \Drupal\slick\SlickManager::getSkinsByGroup()

Returns available slick skins by group.

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

File

src/SlickManager.php, line 63

Class

SlickManager
Implements BlazyManagerInterface, SlickManagerInterface.

Namespace

Drupal\slick

Code

public function getSkinsByGroup($group = '', $option = FALSE) {
  $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 ? Html::escape($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;
  }
  return $group ? array_merge($ungroups, $groups) : $skins;
}