You are here

public function EntityReference::isTargetNew in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php \Drupal\Core\Entity\Plugin\DataType\EntityReference::isTargetNew()
  2. 10 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\DataType

Code

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();
}