function EntityReference::isTargetNew
Same name in other branches
- 8.9.x core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::isTargetNew()
- 10 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::isTargetNew()
- 11.x core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::isTargetNew()
Checks whether the target entity has not been saved yet.
Return value
bool TRUE if the entity is new, FALSE otherwise.
File
-
core/
lib/ Drupal/ Core/ Entity/ Plugin/ DataType/ EntityReference.php, line 59
Class
- EntityReference
- Defines an 'entity_reference' data type.
Namespace
Drupal\Core\Entity\Plugin\DataTypeCode
public function isTargetNew() {
// If only an ID is given, the reference cannot be a new entity.
return !isset($this->id) && isset($this->target) && $this->target
->getValue()
->isNew();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.