You are here

public function PluginConfiguration::setValue in Plugin 8.2

Sets the data value.

Parameters

mixed|null $value: The value to set in the format as documented for the data type or NULL to unset the data value.

bool $notify: (optional) Whether to notify the parent object of the change. Defaults to TRUE. If a property is updated from a parent object, set it to FALSE to avoid being notified again.

Throws

\InvalidArgumentException If the value input is inappropriate.

\Drupal\Core\TypedData\Exception\ReadOnlyException If the data is read-only.

Overrides TypedData::setValue

File

src/Plugin/DataType/PluginConfiguration.php, line 52

Class

PluginConfiguration
Provides a plugin configuration data type.

Namespace

Drupal\plugin\Plugin\DataType

Code

public function setValue($value, $notify = TRUE) {
  $value = (array) $value;
  $plugin_instance = $this->parent
    ->getContainedPluginInstance();
  if ($plugin_instance instanceof ConfigurableInterface || $plugin_instance instanceof ConfigurablePluginInterface) {
    $plugin_instance
      ->setConfiguration($value);
  }
  $this->parent
    ->onChange($this
    ->getName());
}