isLocked; } /** * {@inheritdoc} */ public function lockExclusive(string $entityType): void { $this->isLocked = true; $this->transactionManager->start(); $query = (new LockTableBuilder()) ->table($entityType) ->inExclusiveMode() ->build(); $sql = $this->queryComposer->composeLockTable($query); $this->pdo->exec($sql); } /** * {@inheritdoc} */ public function lockShare(string $entityType): void { $this->isLocked = true; $this->transactionManager->start(); $query = (new LockTableBuilder()) ->table($entityType) ->inShareMode() ->build(); $sql = $this->queryComposer->composeLockTable($query); $this->pdo->exec($sql); } /** * {@inheritdoc} */ public function commit(): void { if (!$this->isLocked) { throw new RuntimeException("Can't commit, it was not locked."); } $this->transactionManager->commit(); $this->isLocked = false; } /** * {@inheritdoc} */ public function rollback(): void { if (!$this->isLocked) { throw new RuntimeException("Can't rollback, it was not locked."); } $this->transactionManager->rollback(); $this->isLocked = false; } }