You are here

public function SlickManager::getSkinsByGroup in Slick Carousel 7.3

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

Returns available slick skins by group.

2 calls to SlickManager::getSkinsByGroup()
SlickManager::attachSkin in src/SlickManager.php
Provides skins only if required.
SlickManager::preRenderWrapper in src/SlickManager.php

File

src/SlickManager.php, line 180

Class

SlickManager
Implements SlickManagerInterface.

Namespace

Drupal\slick

Code

public function getSkinsByGroup($group = '', $option = FALSE) {
  if (!isset($this->skinsByGroup[$group])) {
    $skins = $grouped = $ungrouped = [];
    $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 ? check_plain($properties['name']) : $properties;
      if (!empty($group)) {
        if (isset($properties['group'])) {
          if ($properties['group'] != $group) {
            continue;
          }
          $grouped[$skin] = $item;
        }
        elseif (!$nav_skins) {
          $ungrouped[$skin] = $item;
        }
      }
      $skins[$skin] = $item;
    }
    $this->skinsByGroup[$group] = $group ? array_merge($ungrouped, $grouped) : $skins;
  }
  return $this->skinsByGroup[$group];
}