public function SlickFormatter::preBuildElements in Slick Carousel 8.2
Same name and namespace in other branches
- 7.3 src/SlickFormatter.php \Drupal\slick\SlickFormatter::preBuildElements()
Modifies the field formatter settings inherited by child elements.
Parameters
array $build: The array containing: settings, or potential optionset for extensions.
object $items: The Drupal\Core\Field\FieldItemListInterface items.
array $entities: The optional entities array, not available for non-entities: text, image.
Overrides BlazyFormatter::preBuildElements
File
- src/
SlickFormatter.php, line 32
Class
- SlickFormatter
- Provides Slick field formatters utilities.
Namespace
Drupal\slickCode
public function preBuildElements(array &$build, $items, array $entities = []) {
parent::preBuildElements($build, $items, $entities);
$settings =& $build['settings'];
// Slick specific stuffs.
$build['optionset'] = Slick::loadWithFallback($settings['optionset']);
// Only display thumbnail nav if having at least 2 slides. This might be
// an issue such as for ElevateZoom Plus module, but it should work it out.
if (!isset($settings['nav'])) {
$settings['nav'] = !empty($settings['optionset_thumbnail']) && isset($items[1]);
}
// Do not bother for SlickTextFormatter, or when vanilla is on.
if (empty($settings['vanilla'])) {
$build['optionset']
->whichLazy($settings);
}
else {
// Nothing to work with Vanilla on, disable the asnavfor, else JS error.
$settings['nav'] = FALSE;
}
// Only trim overridables options if disabled.
if (empty($settings['override']) && isset($settings['overridables'])) {
$settings['overridables'] = array_filter($settings['overridables']);
}
$this
->getModuleHandler()
->alter('slick_settings', $build, $items);
}