@param  TransactionHandler  $transaction

@throws \Maatwebsite\Excel\Exceptions\SheetNotFoundException
@throws \PhpOffice\PhpSpreadsheet\Reader\Exception
500958
public function handle(TransactionHandler $transaction)
    {
        if ($this->sheetImport instanceof WithCustomValueBinder) {
            Cell::setValueBinder($this->sheetImport);
        }

        $headingRow = HeadingRowExtractor::headingRow($this->sheetImport);

        $filter = new ChunkReadFilter(
            $headingRow,
            $this->startRow,
            $this->chunkSize,
            $this->sheetName
        );

        $this->reader->setReadFilter($filter);
        $this->reader->setReadDataOnly(true);
        $this->reader->setReadEmptyCells(false);

        $spreadsheet = $this->reader->load(
            $this->temporaryFile->sync()->getLocalPath()
        );

        $sheet = Sheet::byName(
            $spreadsheet,
            $this->sheetName
        );

        if ($sheet->getHighestRow() < $this->startRow) {
            $sheet->disconnect();

            return;
        }

        $transaction(function () use ($sheet) {
            $sheet->import(
                $this->sheetImport,
                $this->startRow
            );

            $sheet->disconnect();
        });
    }
507687
protected function executeInTransaction(string $method) : void
    {
        try {
            $this->database->beginTransaction();

            $this->{$method}();

            $this->database->commit();
        } catch (Exception $exception) {
            $this->database->rollBack();

            $this->handleException($exception);
        }
    }
1283199
function CommitTransaction()
	{
		if ($this->ConnectionSetting->IsReadOnlySlave)
			throw new Exception('Transactions are not allowed on a read-only slave');
		
		$this->RequireConnection(true);
		$this->Observe("DataAdapter ($this->_label) (DataAdapter.CommitTransaction)", OBSERVE_QUERY);
		$this->_transactionInProgress = false;
		return $this->_driver->CommitTransaction($this->_dbconn);
	}
1269191
public function otherTrans(array $transaction = null)
    {
        // morph Transaction extension - will read the type of transaction
        // and instantiate the correct class extending Transaction.
        $morphed = Transaction::create($transaction ?: $this->getAttribute("otherTrans"));

        if ($morphed->type === TransactionType::MULTISIG) {
            // cannot nest multisig in another multisig.
            throw new InvalidArgumentException("It is forbidden to nest a Multisig transaction in another Multisig transaction.");
        }
        elseif ($morphed->type === TransactionType::MULTISIG_SIGNATURE) {
            // cannot nest multisig in another multisig.
            throw new InvalidArgumentException("It is forbidden to nest a Signature transaction in the inner transaction of a Multisig transaction.");
        }

        return $morphed;
    }
816504
private function _submitTransaction($transaction, $txnType)
    {

        try {
            $response = $this->doRequest($transaction);
        } catch (HpsException $e) {
            if ($e->innerException != null && $e->innerException->getMessage() == 'gateway_time-out') {
                throw new HpsException('An error occurred and the gateway has timed out', 'gateway_timeout', $e, 'gateway_timeout');
            }
            throw $e;
        }

        $this->_processGatewayResponse($response, $txnType);

        $rvalue = null;
        switch ($txnType) {
            case 'GetAttachments':
                $rvalue = HpsAttachment::fromDict($response, $txnType);
                break;
            default:
                break;
        }

        return $rvalue;
    }
161597
public static function get_last_by_transaction(Transaction $transaction) {
		$db = Database::Get();
		$id = $db->get_one('SELECT id FROM transaction_log WHERE transaction_id=? ORDER BY created DESC LIMIT 1', [ $transaction->id ]);
		if ($id === null) {
			throw new \Exception('No transaction_log yet');
		}

		return self::get_by_id($id);;
	}
1289189
public function cancelTransaction(string $address): void
    {
        try {
            $result = $this->post(Resources::CANCEL_PENDING_TRANSACTION, ['address' => $address]);
        } catch (ApiErrorException $e) {
            throw new TransactionNotCancelledException($e->getMessage(), $e->getCode(), $e);
        }

        if (!isset($result->success) || $result->success !== ' Pending Transaction cancelled ') {
            throw new ApiErrorException('Canceling transaction failed.');
        }
    }
382929
public static function transformFilterTimestamp($transaction)
    {
        if (isset($transaction->timestamp)) {
            try {
                $transaction->timestamp = new \DateTime($transaction->timestamp);
            } catch (\Exception $e) {
                // Just log the attempt
                error_log($e->getMessage());
            }
        }

        return $transaction;
    }
404164
public final void commit(final PersistentTransaction transaction) throws SevereMessageStoreException
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "commit", "Transaction=" + transaction);

        if (STATE_END_PRECOMMIT == _state)
        {
            // normal processing
        }
        else
        {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())  SibTr.exit(tc, "commit");
            throw new TaskListException(_state);
        }

        _state = STATE_BEGIN_COMMIT;

        Task task = _firstTask;
        while (null != task)
        {
            task.commitInternal(transaction);
            task = task._nextTask;
        }

        task = _firstTask;
        while (null != task)
        {
            task.commitExternal(transaction);
            task = task._nextTask;
        }

        _state = STATE_END_COMMIT;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())  SibTr.exit(tc, "commit");
    }
944224
public function addTransaction(Transaction $transaction)
    {
        $transaction->setAgreement($this);
        $this->transactions->add($transaction);

        return $this;
    }
1095557
public function handleVersionTwo(Transaction $transaction): Transaction
    {
        $transaction->id = Hash::sha256($transaction->serialize())->getHex();

        return $transaction;
    }
1366739
public function getStatus( $transaction = RecordManager::TRANSACTIONS_ALL )
    {

        if( $transaction === RecordManager::TRANSACTIONS_ALL ) {
            return $this->status;
        }

        if( !array_key_exists( $transaction, $this->status ) ) {
            throw new TransactionDoesNotExistException("Transaction with this name `{$transaction}` doesn't exist. Sorry.");
        }

        return array( $transaction => $this->status[$transaction] );

    }
494541
public void stopTransaction(TransactionWrapper transaction) throws DataAccessException {
        if (logger.isTraceEnabled()) {
            logger.trace("stopTransaction");
        }
        if (transaction==null) {
            if (logger.isTraceEnabled())
                logger.trace("   ... transaction is null");
            return;
        }
        if (!transaction.isTransactionAlreadyStarted()) {
            DataAccessException exception = null;
            if (!transaction.isDatabaseConnectionAlreadyOpened()) {
                if (!(db.getConnection() instanceof XAConnection)) {
                    if (transaction.isRollbackOnly()) db.rollback();
                    else {
                        try {
                            db.commit();
                        } catch (SQLException e) {
                            exception = new DataAccessException(0, "Fail to commit", e);
                        }
                    }
                }
                db.closeConnection();
            } else {
                if (logger.isTraceEnabled())
                    logger.trace("   ... database opened by others");
            }
            try {
                TransactionUtil transUtil = TransactionUtil.getInstance();
                TransactionManager transManager = transUtil.getTransactionManager();
                if (transaction.isRollbackOnly()) transManager.rollback();
                else transManager.commit();
                transUtil.setCurrentConnection(null);
                //transUtil.clearCurrentConnection();
            } catch (Exception e) {
                throw new DataAccessException(0, "Fail to stop the transaction", e);
            }
            if (exception!=null) throw exception;
        } else {
            if (logger.isTraceEnabled())
                logger.trace("   ... transaction started by others");
        }
    }
783165
public function beginTransaction()
    {
        if (self::$transaction) {
            throw new TransactionException("Transaction Already Started");
        }

        self::$transaction = true;
        foreach (self::$connectionList as $dbDriver) {
            $dbDriver->beginTransaction();
        }
    }
1156777
public function commitTransaction() {
        // check that a transaction is really active - do not check/renew the connection - renewing a connection breaks the transaction
        if (!$this->getConnection(false)->inTransaction())
            throw new \Exception("Not inside a DB transaction. Cannot commit.");

        try {
            $this->getConnection(false)->commit();
        } catch (Exception $_e) {
            throw new \Exception("Error while committing DB transaction: ".$pe->getMessage());
        }
    }
706619
public function removeTransaction(TransactionInterface $transaction)
    {
        if (!isset($this->handles[$transaction])) {
            throw new AdapterException('Transaction not registered');
        }

        $handle = $this->handles[$transaction];
        $this->handles->detach($transaction);
        $info = curl_getinfo($handle);
        $code = curl_multi_remove_handle($this->multi, $handle);
        curl_close($handle);

        if ($code !== CURLM_OK) {
            MultiAdapter::throwMultiError($code);
        }

        return $info;
    }
264259
public function handleVersionOne(Transaction $transaction): Transaction
    {
        if (isset($transaction->secondSignature)) {
            $transaction->signSignature = $transaction->secondSignature;
        }

        if (Types::VOTE === $transaction->type) {
            $transaction->recipientId = Address::fromPublicKey($transaction->senderPublicKey, $transaction->network);
        }

        if (Types::MULTI_SIGNATURE_REGISTRATION === $transaction->type) {
            $transaction->asset['multisignature']['keysgroup'] = array_map(function ($key) {
                return '+'.$key;
            }, $transaction->asset['multisignature']['keysgroup']);
        }

        if (isset($transaction->vendorFieldHex)) {
            $transaction->vendorField = hex2bin($transaction->vendorFieldHex);
        }

        if (! isset($transaction->id)) {
            $transaction->id = $transaction->getId();
        }

        if (Types::SECOND_SIGNATURE_REGISTRATION === $transaction->type) {
            $transaction->recipientId = Address::fromPublicKey($transaction->senderPublicKey, $transaction->network);
        }

        if (Types::MULTI_SIGNATURE_REGISTRATION === $transaction->type) {
            $transaction->recipientId = Address::fromPublicKey($transaction->senderPublicKey, $transaction->network);
        }

        return $transaction;
    }