You are here

public function GeofieldWidget::preBuild in Openlayers 7.3

Invoked before 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::preBuild

File

modules/openlayers_geofield/src/Plugin/Component/GeofieldWidget/GeofieldWidget.php, line 182
Component: GeofieldWidget.

Class

GeofieldWidget
Class GeofieldWidget.

Namespace

Drupal\openlayers_geofield\Plugin\Component\GeofieldWidget

Code

public function preBuild(array &$build, ObjectInterface $context = NULL) {
  foreach ($context
    ->getCollection()
    ->getObjects('layer') as $layer) {
    if ($layer
      ->getMachineName() == $this
      ->getOption('editLayer', FALSE)) {
      if ($source = $layer
        ->getSource()) {
        if ($source instanceof Vector) {
          $geom = $this
            ->initialDataToGeomFeatures();
          $source
            ->setOption('features', $geom['features']);
        }
      }
    }
  }
}