You are here

public function Random::optionsToObjects in Openlayers 7.3

Same name in this branch
  1. 7.3 modules/openlayers_library/src/Plugin/Style/Random/Random.php \Drupal\openlayers_library\Plugin\Style\Random\Random::optionsToObjects()
  2. 7.3 modules/openlayers_library/src/Plugin/Source/Random/Random.php \Drupal\openlayers_library\Plugin\Source\Random\Random::optionsToObjects()

Return a flat array containing Openlayers Objects from the options array.

Return value

ObjectInterface[] Return a list of objects.

Overrides Base::optionsToObjects

File

modules/openlayers_library/src/Plugin/Source/Random/Random.php, line 87
Source: Random.

Class

Random
Class Random.

Namespace

Drupal\openlayers_library\Plugin\Source\Random

Code

public function optionsToObjects() {
  $import = parent::optionsToObjects();
  foreach ($this
    ->getOptions() as $geometry_type => $data) {
    if ($styles = $this
      ->getOption(array(
      $geometry_type,
      'styles',
    ), array())) {
      foreach ($styles as $style) {
        $style = Openlayers::load('style', $style);

        // This source is a dependency of the current one,
        // we need a lighter weight.
        $this
          ->setWeight($style
          ->getWeight() + 1);
        $import = array_merge($style
          ->getCollection()
          ->getFlatList(), $import);
      }
    }
  }
  return $import;
}