You are here

public function BlockLayerSwitcher::postBuild in Openlayers 7.3

Invoked after an objects render array is built.

Mostly invoked by the map object.

Parameters

array $build: The array with the build information.

\Drupal\openlayers\Types\ObjectInterface $context: The context of the build. Mostly the map object.

Overrides Base::postBuild

File

modules/openlayers_library/src/Plugin/Component/BlockLayerSwitcher/BlockLayerSwitcher.php, line 25
Component: Block Layer Switcher.

Class

BlockLayerSwitcher
Class BlockLayerSwitcher.

Namespace

Drupal\openlayers_library\Plugin\Component\BlockLayerSwitcher

Code

public function postBuild(array &$build, ObjectInterface $context = NULL) {
  if ($context instanceof MapInterface) {
    $olebs_blockswitcher_form = drupal_get_form('olebs_blockswitcher_form', $context);

    // This can rely in the id of the map instead of the css class.
    $olebs_blockswitcher_form['map']['#value'] = $context
      ->getId();
    $build['parameters'][$this
      ->getPluginId()] = array(
      '#type' => 'fieldset',
      '#title' => 'Layer Switcher',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      'form' => $olebs_blockswitcher_form,
    );
  }
}