protected function SlickManager::prepareSettings in Slick Carousel 8.2
Prepare settings for the known module features, not necessarily users'.
1 call to SlickManager::prepareSettings()
- SlickManager::preRenderSlickWrapper in src/
SlickManager.php - One slick_theme() to serve multiple displays: main, overlay, thumbnail.
File
- src/
SlickManager.php, line 237
Class
- SlickManager
- Implements BlazyManagerInterface, SlickManagerInterface.
Namespace
Drupal\slickCode
protected function prepareSettings(array &$element, array &$build) {
$settings = array_merge(SlickDefault::htmlSettings(), $build['settings']);
$id = $settings['id'] = Blazy::getHtmlId('slick', $settings['id']);
$thumb_id = $id . '-thumbnail';
$options = $build['options'];
// Disable draggable for Layout Builder UI to not conflict with UI sortable.
if (strpos($settings['route_name'], 'layout_builder.') === 0 || !empty($settings['is_preview'])) {
$options['draggable'] = FALSE;
}
// Supports programmatic options defined within skin definitions to allow
// addition of options with other libraries integrated with Slick without
// modifying optionset such as for Zoom, Reflection, Slicebox, Transit, etc.
if (!empty($settings['skin']) && ($skins = $this->skinManager
->getSkinsByGroup('main'))) {
if (isset($skins[$settings['skin']]['options'])) {
$options = array_merge($options, $skins[$settings['skin']]['options']);
}
}
// Additional settings.
$build['optionset'] = $build['optionset'] ?: Slick::loadWithFallback($settings['optionset']);
$settings['library'] = $this
->configLoad('library', 'slick.settings');
$settings['breaking'] = $this->skinManager
->isBreaking();
$settings['count'] = empty($settings['count']) ? count($build['items']) : $settings['count'];
$settings['nav'] = $settings['nav'] ?: empty($settings['vanilla']) && !empty($settings['optionset_thumbnail']) && isset($build['items'][1]);
$settings['navpos'] = $settings['nav'] && !empty($settings['thumbnail_position']);
$settings['vertical'] = $build['optionset']
->getSetting('vertical');
$mousewheel = $build['optionset']
->getSetting('mouseWheel');
if ($settings['nav']) {
$options['asNavFor'] = "#{$thumb_id}-slider";
$optionset_thumbnail = $build['optionset_tn'] = Slick::loadWithFallback($settings['optionset_thumbnail']);
$mousewheel = $optionset_thumbnail
->getSetting('mouseWheel');
$settings['vertical_tn'] = $optionset_thumbnail
->getSetting('vertical');
}
else {
// Pass extra attributes such as those from Commerce product variations to
// theme_slick() since we have no asNavFor wrapper here.
if (isset($element['#attributes'])) {
$build['attributes'] = empty($build['attributes']) ? $element['#attributes'] : NestedArray::mergeDeep($build['attributes'], $element['#attributes']);
}
}
// Supports Blazy multi-breakpoint or lightbox images if provided.
// Cases: Blazy within Views gallery, or references without direct image.
if (!empty($settings['check_blazy']) && !empty($settings['first_image'])) {
$this
->isBlazy($settings, $settings['first_image']);
}
// Formatters might have checked this, but not views, nor custom works.
// Why the formatters should check it first? It is so known to children.
if (empty($settings['_lazy'])) {
$build['optionset']
->whichLazy($settings);
}
$settings['mousewheel'] = $mousewheel;
$settings['down_arrow'] = $build['optionset']
->getSetting('downArrow');
$build['options'] = $options;
$build['settings'] = $settings;
$attachments = $this
->attach($settings);
$element['#settings'] = $settings;
$element['#attached'] = empty($build['attached']) ? $attachments : NestedArray::mergeDeep($build['attached'], $attachments);
}