Firestore/src/V1beta1/Gapic/FirestoreGapicClient.php
public function commit($database, $writes, array $optionalArgs = [])
    {
        $request = new CommitRequest();
        $request->setDatabase($database);
        $request->setWrites($writes);
        if (isset($optionalArgs['transaction'])) {
            $request->setTransaction($optionalArgs['transaction']);
        }

        $requestParams = new RequestParamsHeaderDescriptor([
          'database' => $request->getDatabase(),
        ]);
        $optionalArgs['headers'] = isset($optionalArgs['headers'])
            ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
            : $requestParams->getHeader();

        return $this->startCall(
            'Commit',
            CommitResponse::class,
            $optionalArgs,
            $request
        )->wait();
    }
public function commit($database, $writes, array $optionalArgs = [])
    {
        $request = new CommitRequest();
        $request->setDatabase($database);
        $request->setWrites($writes);
        if (isset($optionalArgs['transaction'])) {
            $request->setTransaction($optionalArgs['transaction']);
        }

        $requestParams = new RequestParamsHeaderDescriptor([
          'database' => $request->getDatabase(),
        ]);
        $optionalArgs['headers'] = isset($optionalArgs['headers'])
            ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
            : $requestParams->getHeader();

        return $this->startCall(
            'Commit',
            CommitResponse::class,
            $optionalArgs,
            $request
        )->wait();
    }
public function commit ( $ database , $ writes , array $ optionalArgs = [ ] ) { $ request = new CommitRequest ( ) ; $ request -> setDatabase ( $ database ) ; $ request -> setWrites ( $ writes ) ; if ( isset ( $ optionalArgs [ 'transaction' ] ) ) { $ request -> setTransaction ( $ optionalArgs [ 'transaction' ] ) ; } $ requestParams = new RequestParamsHeaderDescriptor ( [ 'database' => $ request -> getDatabase ( ) , ] ) ; $ optionalArgs [ 'headers' ] = isset ( $ optionalArgs [ 'headers' ] ) ? array_merge ( $ requestParams -> getHeader ( ) , $ optionalArgs [ 'headers' ] ) : $ requestParams -> getHeader ( ) ; return $ this -> startCall ( 'Commit' , CommitResponse :: class , $ optionalArgs , $ request ) -> wait ( ) ; }
Commits a transaction, while optionally updating documents.

Sample code:
```
$firestoreClient = new FirestoreClient();
try {
$formattedDatabase = $firestoreClient->databaseRootName('[PROJECT]', '[DATABASE]');
$writes = [];
$response = $firestoreClient->commit($formattedDatabase, $writes);
} finally {
$firestoreClient->close();
}
```

@param string  $database The database name. In the format:
`projects/{project_id}/databases/{database_id}`.
@param Write[] $writes   The writes to apply.

Always executed atomically and in order.
@param array $optionalArgs {
Optional.

@type string $transaction
If set, applies all writes in this transaction, and commits it.
@type RetrySettings|array $retrySettings
Retry settings to use for this call. Can be a
{@see Google\ApiCore\RetrySettings} object, or an associative array
of retry settings parameters. See the documentation on
{@see Google\ApiCore\RetrySettings} for example usage.
}

@return \Google\Cloud\Firestore\V1beta1\CommitResponse

@throws ApiException if the remote call fails
@experimental
Commits a transaction while optionally updating documents .