You are here

slick.install in Slick Carousel 8.2

Same filename and directory in other branches
  1. 8 slick.install
  2. 7.3 slick.install
  3. 7.2 slick.install

Installation actions for Slick.

File

slick.install
View source
<?php

/**
 * @file
 * Installation actions for Slick.
 */

/**
 * Implements hook_requirements().
 */
function slick_requirements($phase) {
  if ($phase != 'runtime') {
    return [];
  }
  $path = slick('skin')
    ->getSlickPath();
  $exists = $path ? is_file($path . '/slick/slick.min.js') : FALSE;
  if (slick('skin')
    ->config('library') == 'accessible-slick') {
    $name = 'Accessible Slick';
    $url = 'https://github.com/Accessible360/accessible-slick';
    $libpath = '<strong>/libraries/accessible-slick/slick/slick.min.js</strong>';
  }
  else {
    $name = 'Slick';
    $url = 'https://github.com/kenwheeler/slick/';
    $libpath = '<strong>/libraries/slick-carousel/slick/slick.min.js</strong>, or <strong>/libraries/slick/slick/slick.min.js</strong>';
  }
  return [
    'slick_library' => [
      'title' => t('Slick library'),
      'description' => $exists ? '' : t('The <a href=":url">@name library</a> should be installed at @libpath, or any path supported by libraries.module if installed. Check out file or folder permissions if troubled.', [
        ':url' => $url,
        '@name' => $name,
        '@libpath' => $libpath,
      ]),
      'severity' => $exists ? REQUIREMENT_OK : REQUIREMENT_ERROR,
      'value' => $exists ? t('@name library installed at @path', [
        '@name' => $name,
        '@path' => $path,
      ]) : t('@name library not installed', [
        '@name' => $name,
      ]),
    ],
  ];
}

/**
 * Added pauseOnFocus option.
 */
function slick_update_8201() {
  $config = \Drupal::configFactory()
    ->getEditable('slick.optionset.default');
  $config
    ->set('options.settings.pauseOnFocus', TRUE);
  $config
    ->save(TRUE);
}

/**
 * Change skins to use plugin system: https://www.drupal.org/node/3105670.
 */
function slick_update_8202() {

  // Do nothing to clear cache.
}

/**
 * Removed HTML tags from arrows due to translation issue as per #3075838.
 */
function slick_update_8203() {

  // Configuration translation disallowed HTML.
  // See https://drupal.org/node/3075838
  $config_factory = \Drupal::configFactory();
  foreach ($config_factory
    ->listAll('slick.optionset.') as $optionset_name) {
    $optionset = $config_factory
      ->getEditable($optionset_name);
    foreach ([
      'prevArrow',
      'nextArrow',
    ] as $key) {

      // Don't bother with Optimized ON, as arrows are removed already.
      if ($value = $optionset
        ->get('options.settings.' . $key)) {
        $optionset
          ->set('options.settings.' . $key, trim(strip_tags($value)));
      }
    }
    $optionset
      ->save(TRUE);
  }
}

/**
 * Added app.root service to SlickSkinManager.
 */
function slick_update_8204() {

  // Do nothing to clear cache.
}

/**
 * Updated SlickFormatter service to extend BlazyFormatter as per blazy:rc7+.
 */
function slick_update_8205() {

  // Do nothing to clear cache.
}

/**
 * Removing traces of the Slick media module after merging.
 */
function slick_update_8206() {
  $moduleHandler = \Drupal::moduleHandler();
  if (!$moduleHandler
    ->moduleExists('slick_media')) {
    $schema_store = \Drupal::keyValue('system.schema');
    $schema_store
      ->delete('slick_media');
  }
}

/**
 * Added new options provided by Accessible Slick library.
 */
function slick_update_8207() {
  $config = \Drupal::configFactory()
    ->getEditable('slick.optionset.default');
  $config
    ->set('options.settings.regionLabel', 'carousel');
  $config
    ->set('options.settings.useGroupRole', TRUE);
  $config
    ->set('options.settings.instructionsText', '');
  $config
    ->set('options.settings.useAutoplayToggleButton', TRUE);
  $config
    ->set('options.settings.pauseIcon', 'slick-pause-icon');
  $config
    ->set('options.settings.playIcon', 'slick-play-icon');
  $config
    ->set('options.settings.arrowsPlacement', '');
  $config
    ->save(TRUE);
}

Functions

Namesort descending Description
slick_requirements Implements hook_requirements().
slick_update_8201 Added pauseOnFocus option.
slick_update_8202 Change skins to use plugin system: https://www.drupal.org/node/3105670.
slick_update_8203 Removed HTML tags from arrows due to translation issue as per #3075838.
slick_update_8204 Added app.root service to SlickSkinManager.
slick_update_8205 Updated SlickFormatter service to extend BlazyFormatter as per blazy:rc7+.
slick_update_8206 Removing traces of the Slick media module after merging.
slick_update_8207 Added new options provided by Accessible Slick library.