public function Mapping::set

Implements Drupal\Core\TypedData\ComplexDataInterface::set().

Overrides ComplexDataInterface::set

File

drupal/core/lib/Drupal/Core/Config/Schema/Mapping.php, line 55
Contains \Drupal\Core\Config\Schema\Mapping.

Class

Mapping
Defines a mapping configuration element.

Namespace

Drupal\Core\Config\Schema

Code

public function set($property_name, $value, $notify = TRUE) {

  // Notify the parent of any changes to be made.
  if ($notify && isset($this->parent)) {
    $this->parent
      ->onChange($this->name);
  }

  // Set the data into the configuration array but behave according to the
  // interface specification when we've got a null value.
  if (isset($value)) {
    $this->value[$property_name] = $value;
    return $this
      ->get($property_name);
  }
  else {

    // In these objects, when clearing the value, the property is gone.
    // As this needs to return a property, we get it before we delete it.
    $property = $this
      ->get($property_name);
    unset($this->value[$property_name]);
    $property
      ->setValue($value);
    return $property;
  }
}