public function EntityReferenceItem::onChange in Drupal 8
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::onChange()
- 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::onChange()
Parameters
bool $notify: (optional) Whether to forward the notification to the parent. Defaults to TRUE. By passing FALSE, overrides of this method can re-use the logic of parent classes without triggering notification.
Overrides Map::onChange
1 call to EntityReferenceItem::onChange()
- EntityReferenceItem::setValue in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ EntityReferenceItem.php - Sets the data value.
File
- core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ EntityReferenceItem.php, line 226
Class
- EntityReferenceItem
- Defines the 'entity_reference' entity field type.
Namespace
Drupal\Core\Field\Plugin\Field\FieldTypeCode
public function onChange($property_name, $notify = TRUE) {
// Make sure that the target ID and the target property stay in sync.
if ($property_name == 'entity') {
$property = $this
->get('entity');
$target_id = $property
->isTargetNew() ? NULL : $property
->getTargetIdentifier();
$this
->writePropertyValue('target_id', $target_id);
}
elseif ($property_name == 'target_id') {
$this
->writePropertyValue('entity', $this->target_id);
}
parent::onChange($property_name, $notify);
}