You are here

public function Base::clearOption in Openlayers 7.3

Remove an option.

Parameters

string|array $parents: The option to remove. This can be a string or an array of parents keys if the option is in a multilevel array.

Overrides ObjectInterface::clearOption

2 calls to Base::clearOption()
Base::removeObject in src/Types/Base.php
Remove an object from the collection.
OLMap::optionsFormSubmit in src/Plugin/Map/OLMap/OLMap.php
Submit callback for the options form.

File

src/Types/Base.php, line 364
Class Object.

Class

Base
Class Base.

Namespace

Drupal\openlayers\Types

Code

public function clearOption($parents) {
  $ref =& $this->options;
  if (is_string($parents)) {
    $parents = array(
      $parents,
    );
  }
  $last = end($parents);
  reset($parents);
  foreach ($parents as $parent) {
    if (isset($ref) && !is_array($ref)) {
      $ref = array();
    }
    if ($last == $parent) {
      unset($ref[$parent]);
    }
    else {
      if (isset($ref[$parent])) {
        $ref =& $ref[$parent];
      }
      else {
        break;
      }
    }
  }
}