Is there a way to determine if a parameter is an object that is already persisted by Doctrine or not? Something like an entity manager method that checks that an object is not a plain old object but actually something already in memory/persisted.
<?php
public function updateStatus(Entity $entity, EntityStatus $entityStatus)
{
$entityManager = $this->getEntityManager();
try {
// checking persisted entity
if (!$entityManager->isPersisted($entity)) {
throw new InvalidArgumentException('Entity is not persisted');
}
// ...
} catch (InvalidArgumentException $e) {
}
}