function DataReferenceBase::setValue

Same name in other branches
  1. 9 core/lib/Drupal/Core/TypedData/DataReferenceBase.php \Drupal\Core\TypedData\DataReferenceBase::setValue()
  2. 10 core/lib/Drupal/Core/TypedData/DataReferenceBase.php \Drupal\Core\TypedData\DataReferenceBase::setValue()
  3. 11.x core/lib/Drupal/Core/TypedData/DataReferenceBase.php \Drupal\Core\TypedData\DataReferenceBase::setValue()

Overrides TypedData::setValue

1 method overrides DataReferenceBase::setValue()
EntityReference::setValue in core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php
Sets the data value.

File

core/lib/Drupal/Core/TypedData/DataReferenceBase.php, line 45

Class

DataReferenceBase
Base class for typed data references.

Namespace

Drupal\Core\TypedData

Code

public function setValue($value, $notify = TRUE) {
    $this->target = $this->getTypedDataManager()
        ->create($this->definition
        ->getTargetDefinition(), $value);
    // Notify the parent of any changes.
    if ($notify && isset($this->parent)) {
        $this->parent
            ->onChange($this->name);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.