FactoryGirl\Provider\Doctrine\ORM\Repository::useWithPessimisticVersionLock PHP Method

useWithPessimisticVersionLock() public method

FIXME: Only works on entities implementing VersionLockable and does not work in conjunction with the Doctrine @Version column.
public useWithPessimisticVersionLock ( integer $id, mixed $lockVersion, $callback ) : mixed
$id integer
$lockVersion mixed
return mixed callback return type
    public function useWithPessimisticVersionLock($id, $lockVersion, $callback)
    {
        return $this->useWithPessimisticWriteLock($id, function (VersionLockable $entity, EntityManager $em, $self) use($lockVersion, $callback) {
            if ($entity->getVersion() !== $lockVersion) {
                // FIXME: This isn't the appropriate exception type.
                throw OptimisticLockException::lockFailedVersionMissmatch($entity, $lockVersion, $entity->getVersion());
            }
            $entity->incrementVersion();
            return $callback($entity, $em, $self);
        });
    }