8.3.x Entity.php public Entity::isNew()
8.0.x Entity.php public Entity::isNew()
8.1.x Entity.php public Entity::isNew()
8.2.x Entity.php public Entity::isNew()
8.4.x Entity.php public Entity::isNew()

Determines whether the entity is new.

Usually an entity is new if no ID exists for it yet. However, entities may be enforced to be new with existing IDs too.

Return value

bool TRUE if the entity is new, or FALSE if the entity has already been saved.

Overrides EntityInterface::isNew

See also


4 calls to Entity::isNew()
Comment::preSave in core/modules/comment/src/Entity/Comment.php
Acts on an entity before the presave hook is invoked.
ContentEntityBase::hasTranslationChanges in core/lib/Drupal/Core/Entity/ContentEntityBase.php
Determines if the current translation of the entity has unsaved changes.
Entity::delete in core/lib/Drupal/Core/Entity/Entity.php
Deletes an entity permanently.
Entity::getCacheTagsToInvalidate in core/lib/Drupal/Core/Entity/Entity.php
Returns the cache tags that should be used to invalidate caches.
2 methods override Entity::isNew()
ConfigEntityBase::isNew in core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
Overrides Entity::isNew().
User::isNew in core/modules/user/src/Entity/User.php
Determines whether the entity is new.


core/lib/Drupal/Core/Entity/Entity.php, line 125


Defines a base entity class.




public function isNew() {
  return !empty($this->enforceIsNew) || !$this->id();