class FlickityBuilder in Flickity Carousel 3.0.x
Provides a trusted callback to alter the flickity output.
Hierarchy
- class \Drupal\flickity\FlickityBuilder implements RenderCallbackInterface
Expanded class hierarchy of FlickityBuilder
See also
1 file declares its use of FlickityBuilder
File
- src/
FlickityBuilder.php, line 12
Namespace
Drupal\flickityView source
class FlickityBuilder implements RenderCallbackInterface {
/**
* Sets the flickity - #pre_render callback.
*/
public static function preRender(array $element) {
$items = array();
foreach ($element['#output']['items'] as $key => $item) {
$items[] = array(
'#theme' => 'flickity_item',
'#item' => $item['row'],
'#attributes' => array(
'class' => array(
'gallery-cell',
'item-' . $key,
),
),
);
}
// Build wrapper with Flickity items.
$build = flickity_build($element['#output']['settings'], $items);
// Provide pre render alter.
\Drupal::moduleHandler()
->alter('pre_render', $build);
// Render the complete Flickity element.
$element['#children'] = \Drupal::service('renderer')
->render($build);
return $element;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FlickityBuilder:: |
public static | function | Sets the flickity - #pre_render callback. |