Skip to content

Commit

Permalink
Add Firestore to service builder (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpedrie authored and dwsupplee committed Nov 30, 2017
1 parent fa09d12 commit 4e6f23d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
27 changes: 26 additions & 1 deletion src/Core/ServiceBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
use Google\Auth\HttpHandler\HttpHandlerFactory;
use Google\Cloud\BigQuery\BigQueryClient;
use Google\Cloud\Datastore\DatastoreClient;
use Google\Cloud\Logging\LoggingClient;
use Google\Cloud\Firestore\FirestoreClient;
use Google\Cloud\Language\LanguageClient;
use Google\Cloud\Logging\LoggingClient;
use Google\Cloud\PubSub\PubSubClient;
use Google\Cloud\Spanner\SpannerClient;
use Google\Cloud\Speech\SpeechClient;
Expand Down Expand Up @@ -145,6 +146,30 @@ public function datastore(array $config = [])
return $this->createClient(DatastoreClient::class, 'datastore', $config);
}

/**
* Cloud Firestore is a flexible, scalable, realtime database for mobile,
* web, and server development. Find more information at the
* [Google Cloud firestore docs](https://cloud.google.com/firestore/docs/).
*
* Example:
* ```
* $firestore = $cloud->firestore();
* ```
*
* @param array $config [optional] {
* Configuration options. See
* {@see Google\Cloud\Core\ServiceBuilder::__construct()} for the other available options.
*
* @type bool $returnInt64AsObject If true, 64 bit integers will be
* returned as a {@see Google\Cloud\Core\Int64} object for 32 bit
* platform compatibility. **Defaults to** false.
* @return FirestoreClient
*/
public function firestore(array $config = [])
{
return $this->createClient(FirestoreClient::class, 'firestore', $config);
}

/**
* Google Stackdriver Logging allows you to store, search, analyze, monitor,
* and alert on log data and events from Google Cloud Platform and Amazon
Expand Down
4 changes: 3 additions & 1 deletion tests/snippets/Core/ServiceBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
use Google\Cloud\Core\ServiceBuilder;
use Google\Cloud\Datastore\DatastoreClient;
use Google\Cloud\Dev\Snippet\SnippetTestCase;
use Google\Cloud\Logging\LoggingClient;
use Google\Cloud\Firestore\FirestoreClient;
use Google\Cloud\Language\LanguageClient;
use Google\Cloud\Logging\LoggingClient;
use Google\Cloud\PubSub\PubSubClient;
use Google\Cloud\Spanner\SpannerClient;
use Google\Cloud\Speech\SpeechClient;
Expand Down Expand Up @@ -54,6 +55,7 @@ public function serviceBuilderMethods()
return [
['bigQuery', BigQueryClient::class, 'bigQuery'],
['datastore', DatastoreClient::class, 'datastore'],
['firestore', FirestoreClient::class, 'firestore', true],
['logging', LoggingClient::class, 'logging'],
['language', LanguageClient::class, 'language'],
['pubsub', PubSubClient::class, 'pubsub'],
Expand Down
8 changes: 7 additions & 1 deletion tests/unit/Core/ServiceBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
namespace Google\Cloud\Tests\Unit;

use Google\Cloud\BigQuery\BigQueryClient;
use Google\Cloud\Core\ServiceBuilder;
use Google\Cloud\Datastore\DatastoreClient;
use Google\Cloud\Firestore\FirestoreClient;
use Google\Cloud\Language\LanguageClient;
use Google\Cloud\Logging\LoggingClient;
use Google\Cloud\PubSub\PubSubClient;
use Google\Cloud\Core\ServiceBuilder;
use Google\Cloud\Spanner\SpannerClient;
use Google\Cloud\Speech\SpeechClient;
use Google\Cloud\Storage\StorageClient;
Expand Down Expand Up @@ -80,6 +81,11 @@ public function serviceProvider()
], [
'datastore',
DatastoreClient::class
], [
'firestore',
FirestoreClient::class,
[],
[$this, 'checkAndSkipGrpcTests']
], [
'logging',
LoggingClient::class
Expand Down

0 comments on commit 4e6f23d

Please sign in to comment.