Skip to content

Instantly share code, notes, and snippets.

@netcell
Created May 15, 2016 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netcell/1fc8baa53b91cd64b8e281d324afa5cf to your computer and use it in GitHub Desktop.
Save netcell/1fc8baa53b91cd64b8e281d324afa5cf to your computer and use it in GitHub Desktop.
gds-php wrapper Type definition
<?php
namespace App\Datastore\Abstracts;
class Type {
const String = 1;
const Integer = 2;
const Datetime = 3;
const Float = 4;
const Boolean = 5;
const StringList = 6;
const Geopoint = 7;
const Json = 8;
public static function setProperty($obj_schema, $property, $type, $index = FALSE) {
switch ($type) {
case self::String:
$obj_schema->addString($property, $index);
break;
case self::Integer:
$obj_schema->addInteger($property, $index);
break;
case self::Datetime:
$obj_schema->addDatetime($property, $index);
break;
case self::Float:
$obj_schema->addFloat($property, $index);
break;
case self::Boolean:
$obj_schema->addBoolean($property, $index);
break;
case self::StringList:
$obj_schema->addStringList($property, $index);
break;
case self::Geopoint:
$obj_schema->addGeopoint($property, $index);
break;
case self::Json:
$obj_schema->addString($property, $index);
break;
default:
if ($index) throw new Exception("Invalid Datastore Entity Property Type", 1);
else self::setProperty($obj_schema, $property, $type[0], TRUE);
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment