2

I'm using the hook

function nvgh_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
}

but I only need to do something when the node is new (not when it is edited). How to do this? I'm inspecting the entity with kint but cannot find a good indicator for this... also kint is disappearing as the node view is redirected into view modes.

How to do this?

0
4

Use the Entity::isNew() method:

if ($entity->isNew()) {
  // ...
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.