You are here

public function Map::optionsToObjects in Openlayers 7.3

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

Return value

ObjectInterface[] Return a list of objects.

Overrides Base::optionsToObjects

File

src/Types/Map.php, line 231
Class Map.

Class

Map
Class Map.

Namespace

Drupal\openlayers\Types

Code

public function optionsToObjects() {
  $import = array();

  // TODO: Simplify this.
  // Add the objects from the configuration.
  foreach (Openlayers::getPluginTypes(array(
    'map',
  )) as $weight_type => $type) {
    foreach ($this
      ->getOption($type . 's', array()) as $weight => $object) {
      if (!$this
        ->getCollection()
        ->getObjectById($type, $object)) {
        if ($merge_object = Openlayers::load($type, $object)) {
          $merge_object
            ->setWeight($weight_type . '.' . $weight);
          $import[$type . '_' . $merge_object
            ->getMachineName()] = $merge_object;
        }
      }
    }
  }
  foreach ($this
    ->getCollection()
    ->getFlatList() as $object) {
    $import[$object
      ->getType() . '_' . $object
      ->getMachineName()] = $object;
  }
  return $import;
}