1

Is there a way to check if an entity is locked with doctrine ?

In my case, I need to know from an EventListener if a related entity has been locked in current transaction to prevent logic errors.

Something like this would be great :

// Somewhere
$foo = $repository->find($id, LockMode::PESSIMISTIC_WRITE);
$em->flush(); // Trigger the event listener
...

// In the event listener (prePersist for example)
$foo = $bar->getFoo();
if ($...->isLocked($foo)) {  // The method I need
    ...
}

I'd like to avoid using additional vendors.

0 Answers0