You are here

protected function TransactorHandler::executionLockAcquire in Transaction 8

Locks a transaction for execution.

Parameters

\Drupal\transaction\TransactionInterface $transaction: The transaction to lock.

Return value

string|false The lock name if the transaction where successfully locked for execution, FALSE if the transaction is locked and the locking timeout was exceeded.

1 call to TransactorHandler::executionLockAcquire()
TransactorHandler::doExecute in src/TransactorHandler.php
Executes a transaction.

File

src/TransactorHandler.php, line 189

Class

TransactorHandler
Transactor entity handler.

Namespace

Drupal\transaction

Code

protected function executionLockAcquire(TransactionInterface $transaction) {
  $lock_name = 'transaction_' . $transaction
    ->getTypeId() . '_' . $transaction
    ->getTargetEntityId();
  $lock_time = ini_get('max_execution_time') ?: 3600;
  if ($this->lock
    ->acquire($lock_name, $lock_time) || !$this->lock
    ->wait($lock_name) && $this->lock
    ->acquire($lock_name, $lock_time)) {
    return $lock_name;
  }
  return FALSE;
}