PHP Class GDS\Gateway

Persists and retrieves Entities to/from Google Cloud Datastore. This class is designed to work FOR the \GDS\Store, it is not generally expected to be used directly by the application developer
Author: Tom Walder ([email protected])
Datei anzeigen Open project: tomwalder/php-gds

Protected Properties

Property Type Description
$arr_kind_mappers Mapper[] An array of Mappers, keyed on Entity Kind
$obj_last_response object | null The last response - usually a Commit or Query response
$obj_schema Schema | null The current Schema
$str_dataset_id string | null The dataset ID
$str_namespace string | null Optional namespace (for multi-tenant applications)
$str_next_transaction null | string The transaction ID to use on the next commit

Public Methods

Method Description
beginTransaction ( boolean $bol_cross_group = FALSE ) : mixed Start a transaction
delete ( Entity $obj_key ) : boolean Delete an Entity
deleteMulti ( array $arr_entities ) : mixed Delete 1-many entities
fetchById ( $int_key_id ) : mixed Fetch one entity by Key ID
fetchByIds ( array $arr_key_ids ) : array Fetch one or more entities by KeyID
fetchByName ( $str_key_name ) : mixed Fetch entity data by Key Name
fetchByNames ( array $arr_key_names ) : array Fetch one or more entities by KeyName
getEndCursor ( ) : mixed Get the end cursor from the last response
gql ( string $str_gql, null | array $arr_params = null ) : mixed Fetch some Entities, based on the supplied GQL and, optionally, parameters
put ( Entity $obj_entity ) Put a single Entity into the Datastore
putMulti ( array $arr_entities ) Put an array of Entities into the Datastore
withSchema ( Schema $obj_schema ) Set the Schema to be used next (once?)
withTransaction ( $str_transaction_id ) Set the transaction ID to be used next (once)

Protected Methods

Method Description
configureObjectValueParamForQuery ( object $obj_val, object $mix_value ) Configure a Value parameter, based on the supplied object-type value
configureValueParamForQuery ( $obj_val, $mix_value ) Part of our "add parameters to query" sequence.
createMapper ( ) : Mapper Create a mapper that's right for this Gateway
determineMapper ( Entity $obj_gds_entity ) : Mapper Determine Mapper (early stage [draft] support for cross-entity upserts)
ensureSchema ( Entity[] $arr_entities ) Default Kind & Schema support for "new" Entities
extractAutoIDs ( ) : array Extract Auto Insert IDs from the last response
fetchByKeyPart ( array $arr_key_parts, $str_setter ) : mixed Fetch 1-many Entities, using the Key parts provided
mapAutoIDs ( array $arr_auto_id_requested ) Record the Auto-generated Key IDs against the GDS Entities.
upsert ( array $arr_entities ) : Entity[] Put an array of Entities into the Datastore. Return any that need AutoIDs

Method Details

beginTransaction() abstract public method

Start a transaction
abstract public beginTransaction ( boolean $bol_cross_group = FALSE ) : mixed
$bol_cross_group boolean
return mixed

configureObjectValueParamForQuery() abstract protected method

Configure a Value parameter, based on the supplied object-type value
abstract protected configureObjectValueParamForQuery ( object $obj_val, object $mix_value )
$obj_val object
$mix_value object

configureValueParamForQuery() protected method

Shared between multiple Gateway implementations.
protected configureValueParamForQuery ( $obj_val, $mix_value )
$obj_val
$mix_value

createMapper() abstract protected method

Create a mapper that's right for this Gateway
abstract protected createMapper ( ) : Mapper
return Mapper

delete() public method

Delete an Entity
public delete ( Entity $obj_key ) : boolean
$obj_key Entity
return boolean

deleteMulti() abstract public method

Delete 1-many entities
abstract public deleteMulti ( array $arr_entities ) : mixed
$arr_entities array
return mixed

determineMapper() protected method

Determine Mapper (early stage [draft] support for cross-entity upserts)
protected determineMapper ( Entity $obj_gds_entity ) : Mapper
$obj_gds_entity Entity
return Mapper

ensureSchema() protected method

Default Kind & Schema support for "new" Entities
protected ensureSchema ( Entity[] $arr_entities )
$arr_entities Entity[]

extractAutoIDs() abstract protected method

Extract Auto Insert IDs from the last response
abstract protected extractAutoIDs ( ) : array
return array

fetchById() public method

Fetch one entity by Key ID
public fetchById ( $int_key_id ) : mixed
$int_key_id
return mixed

fetchByIds() public method

Consumes Schema (deferred)
public fetchByIds ( array $arr_key_ids ) : array
$arr_key_ids array
return array

fetchByKeyPart() abstract protected method

Consumes Schema
abstract protected fetchByKeyPart ( array $arr_key_parts, $str_setter ) : mixed
$arr_key_parts array
$str_setter
return mixed

fetchByName() public method

Fetch entity data by Key Name
public fetchByName ( $str_key_name ) : mixed
$str_key_name
return mixed

fetchByNames() public method

Consume Schema (deferred)
public fetchByNames ( array $arr_key_names ) : array
$arr_key_names array
return array

getEndCursor() abstract public method

Get the end cursor from the last response
abstract public getEndCursor ( ) : mixed
return mixed

gql() abstract public method

Fetch some Entities, based on the supplied GQL and, optionally, parameters
abstract public gql ( string $str_gql, null | array $arr_params = null ) : mixed
$str_gql string
$arr_params null | array
return mixed

mapAutoIDs() protected method

Record the Auto-generated Key IDs against the GDS Entities.
protected mapAutoIDs ( array $arr_auto_id_requested )
$arr_auto_id_requested array

put() public method

Put a single Entity into the Datastore
public put ( Entity $obj_entity )
$obj_entity Entity

putMulti() public method

Consumes Schema
public putMulti ( array $arr_entities )
$arr_entities array

upsert() abstract protected method

Put an array of Entities into the Datastore. Return any that need AutoIDs
abstract protected upsert ( array $arr_entities ) : Entity[]
$arr_entities array
return Entity[]

withSchema() public method

Set the Schema to be used next (once?)
public withSchema ( Schema $obj_schema )
$obj_schema Schema

withTransaction() public method

Set the transaction ID to be used next (once)
public withTransaction ( $str_transaction_id )
$str_transaction_id

Property Details

$arr_kind_mappers protected_oe property

An array of Mappers, keyed on Entity Kind
protected Mapper[],GDS $arr_kind_mappers
return Mapper[]

$obj_last_response protected_oe property

The last response - usually a Commit or Query response
protected object|null $obj_last_response
return object | null

$obj_schema protected_oe property

The current Schema
protected Schema,gds|null $obj_schema
return Schema | null

$str_dataset_id protected_oe property

The dataset ID
protected string|null $str_dataset_id
return string | null

$str_namespace protected_oe property

Optional namespace (for multi-tenant applications)
protected string|null $str_namespace
return string | null

$str_next_transaction protected_oe property

The transaction ID to use on the next commit
protected null|string $str_next_transaction
return null | string