You are here

class FlickityBuilder in Flickity Carousel 3.0.x

Provides a trusted callback to alter the flickity output.

Hierarchy

Expanded class hierarchy of FlickityBuilder

See also

theme_flickity()

1 file declares its use of FlickityBuilder
flickity.theme.inc in theme/flickity.theme.inc
flickity.theme.inc

File

src/FlickityBuilder.php, line 12

Namespace

Drupal\flickity
View 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

Namesort descending Modifiers Type Description Overrides
FlickityBuilder::preRender public static function Sets the flickity - #pre_render callback.