You are here

public function SlickManager::build in Slick Carousel 8

Same name and namespace in other branches
  1. 8.2 src/SlickManager.php \Drupal\slick\SlickManager::build()
  2. 7.3 src/SlickManager.php \Drupal\slick\SlickManager::build()

Returns a renderable array of both main and thumbnail slick instances.

Parameters

array $build: An associative array containing:

  • items: An array of slick contents: text, image or media.
  • options: An array of key:value pairs of custom JS overrides.
  • optionset: The cached optionset object to avoid multiple invocations.
  • settings: An array of key:value pairs of HTML/layout related settings.
  • thumb: An associative array of slick thumbnail following the same structure as the main display: $build['thumb']['items'], etc.

Return value

array The renderable array of both main and thumbnail slick instances.

Overrides SlickManagerInterface::build

File

src/SlickManager.php, line 343

Class

SlickManager
Implements BlazyManagerInterface, SlickManagerInterface.

Namespace

Drupal\slick

Code

public function build(array $build = []) {
  foreach ([
    'items',
    'options',
    'optionset',
    'settings',
  ] as $key) {
    $build[$key] = isset($build[$key]) ? $build[$key] : [];
  }
  return empty($build['items']) ? [] : [
    '#theme' => 'slick_wrapper',
    '#items' => [],
    '#build' => $build,
    '#pre_render' => [
      [
        $this,
        'preRenderSlickWrapper',
      ],
    ],
    // Satisfy CTools blocks as per 2017/04/06: 2804165 which expects children
    // only, but not #theme, #type, #markup properties.
    // @todo: Remove when CTools is more accommodative.
    'items' => [],
  ];
}