You are here

public function SlickSkinManager::getSkins in Slick Carousel 8.2

Returns slick skins registered via SlickSkin plugin and or defaults.

File

src/SlickSkinManager.php, line 149

Class

SlickSkinManager
Provides Slick skin manager.

Namespace

Drupal\slick

Code

public function getSkins() {
  if (!isset($this->skinDefinition)) {
    $cid = 'slick_skins_data';
    if ($cache = $this->cacheBackend
      ->get($cid)) {
      $this->skinDefinition = $cache->data;
    }
    else {
      $methods = [
        'skins',
        'arrows',
        'dots',
      ];
      $skins = $items = [];
      foreach ($this
        ->loadMultiple() as $skin) {
        foreach ($methods as $method) {
          $items[$method] = $skin
            ->{$method}();
        }
        $skins = NestedArray::mergeDeep($skins, $items);
      }

      // @todo remove for the new plugin system at slick:8.x-3.0.
      $disabled = $this
        ->config('disable_old_skins');
      if (empty($disabled)) {
        if ($old_skins = $this
          ->buildSkins($methods)) {
          $skins = NestedArray::mergeDeep($old_skins, $skins);
        }
      }
      $count = isset($items['skins']) ? count($items['skins']) : count($items);
      $tags = Cache::buildTags($cid, [
        'count:' . $count,
      ]);
      $this->cacheBackend
        ->set($cid, $skins, Cache::PERMANENT, $tags);
      $this->skinDefinition = $skins;
    }
  }
  return $this->skinDefinition;
}