You are here

public function TransactorBase::executeTransaction in Transaction 8

Executes a transaction.

By calling this method, the transactor will set the result code in the transaction.

Parameters

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

\Drupal\transaction\TransactionInterface $last_executed: The last executed transaction with the same type and target. Empty if this is the first one.

Return value

bool TRUE if transaction was executed, FALSE otherwise.

Overrides TransactorPluginInterface::executeTransaction

See also

\Drupal\transaction\TransactionInterface::getResultCode()

1 call to TransactorBase::executeTransaction()
GenericTransactor::executeTransaction in src/Plugin/Transaction/GenericTransactor.php
Executes a transaction.
1 method overrides TransactorBase::executeTransaction()
GenericTransactor::executeTransaction in src/Plugin/Transaction/GenericTransactor.php
Executes a transaction.

File

src/TransactorBase.php, line 721

Class

TransactorBase
Provides a base class for transactor plugins.

Namespace

Drupal\transaction

Code

public function executeTransaction(TransactionInterface $transaction, TransactionInterface $last_executed = NULL) {
  if ($result = $transaction
    ->isPending() && $transaction
    ->getTargetEntityId()) {
    $transaction
      ->setResultCode(TransactorPluginInterface::RESULT_OK);
  }
  else {
    $transaction
      ->setResultCode(TransactorPluginInterface::RESULT_ERROR);
  }
  return $result;
}