You are here

public function GridStackEnginePluginBase::build in GridStack 8.2

Alters GridStack build.

Parameters

array $build: An associative array containing:

  • items: An array of gridstack contents: text, image or media.
  • options: An array of key:value pairs of custom JS options.
  • optionset: The cached optionset object to avoid multiple invocations.
  • settings: An array of key:value pairs of HTML/layout related settings.

array $element: The render element being modified.

Overrides GridStackEnginePluginInterface::build

1 call to GridStackEnginePluginBase::build()
GridStackBase::build in src/Plugin/gridstack/engine/GridStackBase.php
Alters GridStack build.
1 method overrides GridStackEnginePluginBase::build()
GridStackBase::build in src/Plugin/gridstack/engine/GridStackBase.php
Alters GridStack build.

File

src/GridStackEnginePluginBase.php, line 216

Class

GridStackEnginePluginBase
Provides base class for all gridstack layout engines.

Namespace

Drupal\gridstack

Code

public function build(array &$build, array &$element) {
  $settings =& $build['settings'];

  // Allows a layout variant to modify the established optionset.
  // Since render array output is cached, nothing to lose, just flexibility.
  if (!$this->optionset || !empty($settings['_variant'])) {
    $this
      ->setOptionset($build['optionset']);
  }

  // Defines stuffs early to be processed by ::buildItems.
  $this
    ->prepare($element, $settings);
  $element['#items'] = $this->stylizer
    ->getStyle('contentless', $settings) ? [] : $this
    ->buildItems($build);

  // Attached layout inline styles if so configured.
  // Runs after ::buildItems to aggregate styles.
  if ($styles = $this
    ->styles()) {
    $this->stylizer
      ->rootStyles($element, $styles, $settings);
  }
}