Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Firestore session handler. #2258

Merged
merged 20 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Firestore/src/FirestoreClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -573,4 +573,51 @@ public function fieldPath(array $fieldNames)
{
return new FieldPath($fieldNames);
}

/**
* Returns a FirestoreSessionHandler.
*
* Example:
* ```
* $handler = $firestore->sessionHandler();
*
* // Configure PHP to use the Firestore session handler.
* session_set_save_handler($handler, true);
* session_save_path('sessions');
* session_start();
*
* // Then write and read the $_SESSION array.
* $_SESSION['name'] = 'Bob';
* echo $_SESSION['name'];
* ```
*
* @param array $options [optional] {
* Configuration Options.
*
* @type int $gcLimit The number of entities to delete in the garbage
* collection. Values larger than 1000 will be limited to 1000.
* **Defaults to** `0`, indicating garbage collection is disabled by
* default.
* @type string $collectionNameTemplate A sprintf compatible template
* for formatting the collection name where sessions will be stored.
* The template receives two values, the first being the save path
* and the latter being the session name.
* @type array $begin Configuration options for beginTransaction.
* @type array $commit Configuration options for commit.
* @type array $rollback Configuration options for rollback.
* @type array $read Configuration options for read.
* @type array $query Configuration options for runQuery.
* }
* @return FirestoreSessionHandler
*/
public function sessionHandler(array $options = [])
{
return new FirestoreSessionHandler(
$this->connection,
$this->valueMapper,
$this->projectId,
$this->database,
$options
);
}
}
Loading