PHP Class Google\Cloud\Datastore\EntityMapper

Inheritance: use trait Google\Cloud\ArrayTrait, use trait DatastoreTrait
Show file Open project: GoogleCloudPlatform/gcloud-php Class Usage Examples

Public Methods

Method Description
__construct ( string $projectId, boolean $encode, boolean $returnInt64AsObject ) Create an Entity Mapper
convertValue ( string $type, mixed $value ) : mixed Convert a Datastore value object to a simple value
objectProperty ( mixed $value ) : array Convert different object types to API values
objectToRequest ( Entity $entity ) : array Translate an Entity to a datastore representation.
responseToEntityProperties ( array $entityData ) : array Convert an entity response to properties, excludes and meanings.
valueObject ( mixed $value, boolean $exclude = false, integer $meaning = null ) : array Format values for the API

Private Methods

Method Description
convertArrayToArrayValue ( array $value ) : array Convert a non-associative array to a datastore arrayValue type
convertArrayToEntityValue ( array $value ) : array Convert an associative array to a datastore entityValue type
getPropertyValue ( array $property ) : mixed Determine the property type and return a converted value
getValueType ( array $value ) : string Get the value type from a value object.
isEncoded ( $value )

Method Details

__construct() public method

Create an Entity Mapper
public __construct ( string $projectId, boolean $encode, boolean $returnInt64AsObject )
$projectId string The datastore project ID
$encode boolean Whether to encode blobs as base64.
$returnInt64AsObject boolean If true, 64 bit integers will be returned as a {@see \Google\Cloud\Int64} object for 32 bit platform compatibility.

convertValue() public method

Convert a Datastore value object to a simple value
public convertValue ( string $type, mixed $value ) : mixed
$type string The value type
$value mixed The value
return mixed

objectProperty() public method

Convert different object types to API values
public objectProperty ( mixed $value ) : array
$value mixed The value object
return array

objectToRequest() public method

Translate an Entity to a datastore representation.
public objectToRequest ( Entity $entity ) : array
$entity Entity The input entity.
return array A Datastore [Entity](https://cloud.google.com/datastore/reference/rest/v1/Entity)

responseToEntityProperties() public method

Convert an entity response to properties, excludes and meanings.
public responseToEntityProperties ( array $entityData ) : array
$entityData array The incoming entity
return array

valueObject() public method

Format values for the API
public valueObject ( mixed $value, boolean $exclude = false, integer $meaning = null ) : array
$value mixed
$exclude boolean [optional] If true, value will be excluded from datastore indexes.
$meaning integer [optional] The Meaning value. Maintained only for backwards compatibility.
return array