getObject(); $now = new DateTimeImmutable(); $user = $this->security->getUser(); if ($entity instanceof TimestampableInterface) { $entity->setCreatedAt($now); $entity->setUpdatedAt($now); } if ($entity instanceof BlamableInterface && $user instanceof UserInterface) { $entity->setCreatedBy($user); $entity->setUpdatedBy($user); } } public function preUpdate(PreUpdateEventArgs $args): void { $entity = $args->getObject(); $user = $this->security->getUser(); if ($entity instanceof TimestampableInterface) { $entity->setUpdatedAt(new DateTimeImmutable()); } if ($entity instanceof BlamableInterface && $user instanceof UserInterface) { $entity->setUpdatedBy($user); } } }