Spanner/src/TransactionConfigurationTrait.php
private function transactionOptions(array &$options, array $previous = [])
    {
        $options += [
            'begin' => false,
            'transactionType' => SessionPoolInterface::CONTEXT_READWRITE,
            'transactionId' => null,
        ];

        $type = null;

        $context = $this->pluck('transactionType', $options);
        $id = $this->pluck('transactionId', $options);

        $begin = $this->pluck('begin', $options);
        if ($id === null) {
            if ($begin) {
                $type = 'begin';
            } else {
                $type = 'singleUseTransaction';
                $options['singleUse'] = true;
            }
        }

        if ($id !== null) {
            $type = 'transactionId';
            $transactionOptions = $id;
        } elseif ($context === SessionPoolInterface::CONTEXT_READ) {
            $transactionOptions = $this->configureSnapshotOptions($options, $previous);
        } elseif ($context === SessionPoolInterface::CONTEXT_READWRITE) {
            $transactionOptions = $this->configureTransactionOptions();
        } else {
            throw new \BadMethodCallException(sprintf(
                'Invalid transaction context %s',
                $context
            ));
        }

        return [$transactionOptions, $type, $context];
    }
private function transactionOptions(array &$options, array $previous = [])
    {
        $options += [
            'begin' => false,
            'transactionType' => SessionPoolInterface::CONTEXT_READWRITE,
            'transactionId' => null,
        ];

        $type = null;

        $context = $this->pluck('transactionType', $options);
        $id = $this->pluck('transactionId', $options);

        $begin = $this->pluck('begin', $options);
        if ($id === null) {
            if ($begin) {
                $type = 'begin';
            } else {
                $type = 'singleUseTransaction';
                $options['singleUse'] = true;
            }
        }

        if ($id !== null) {
            $type = 'transactionId';
            $transactionOptions = $id;
        } elseif ($context === SessionPoolInterface::CONTEXT_READ) {
            $transactionOptions = $this->configureSnapshotOptions($options, $previous);
        } elseif ($context === SessionPoolInterface::CONTEXT_READWRITE) {
            $transactionOptions = $this->configureTransactionOptions();
        } else {
            throw new \BadMethodCallException(sprintf(
                'Invalid transaction context %s',
                $context
            ));
        }

        return [$transactionOptions, $type, $context];
    }
private function transactionOptions ( array & $ options , array $ previous = [ ] ) { $ options += [ 'begin' => false , 'transactionType' => SessionPoolInterface :: CONTEXT_READWRITE , 'transactionId' => null , ] ; $ type = null ; $ context = $ this -> pluck ( 'transactionType' , $ options ) ; $ id = $ this -> pluck ( 'transactionId' , $ options ) ; $ begin = $ this -> pluck ( 'begin' , $ options ) ; if ( $ id === null ) { if ( $ begin ) { $ type = 'begin' ; } else { $ type = 'singleUseTransaction' ; $ options [ 'singleUse' ] = true ; } } if ( $ id !== null ) { $ type = 'transactionId' ; $ transactionOptions = $ id ; } elseif ( $ context === SessionPoolInterface :: CONTEXT_READ ) { $ transactionOptions = $ this -> configureSnapshotOptions ( $ options , $ previous ) ; } elseif ( $ context === SessionPoolInterface :: CONTEXT_READWRITE ) { $ transactionOptions = $ this -> configureTransactionOptions ( ) ; } else { throw new \ BadMethodCallException ( sprintf ( 'Invalid transaction context %s' , $ context ) ) ; } return [ $ transactionOptions , $ type , $ context ] ; }
Return transaction options based on given configuration options.

@param array $options call options.
@param array $previous Previously given call options (for single-use snapshots).
@return array [(array) transaction options, (string) transaction type, (string) context]
Return transaction options based on given configuration options .