FactoryGirl\Provider\Doctrine\ORM\Locking\TableLock::transaction PHP Method

transaction() public method

Attempt to acquire a table level lock in MySQL for the duration of the given transaction. IS NOT IN ANY WAY GUARANTEED TO WORK. MySQL requires that the aliases through which a table is accessed during this transaction are enumerated when locking tables, which due to the nature of Doctrine is a somewhat difficult task. Nevertheless, in simple cases a good guesstimate as to the table aliases can be made; see relevant methods below.
public transaction ( integer $lockMode, callback $transaction ) : mixed
$lockMode integer a TableLockMode constant
$transaction callback
return mixed
    public function transaction($lockMode, $transaction)
    {
        $lock = $this->getLockString($lockMode);
        $unlock = $this->getUnlockString();
        return $this->getRepository()->transaction(function (EntityManager $em, Repository $repository) use($lock, $unlock, $transaction) {
            $conn = $em->getConnection();
            $conn->executeQuery($lock);
            try {
                $result = $repository->transaction($transaction);
                $conn->executeQuery($unlock);
                return $result;
            } catch (Exception $e) {
                // Transaction rollback does not release table locks
                $conn->executeQuery($unlock);
                throw $e;
            }
        });
    }