Пример #1
0
 /**
  * @param \Google_Service_Datastore_Value|mixed $value
  * @param Type|string $type
  * @return $this
  */
 public function withValue($value, $type = null)
 {
     if (!$value instanceof \Google_Service_Datastore_Value) {
         $value = \DatastoreHelper::newValue($value, $type);
     }
     $this->value = $value;
     return $this;
 }
Пример #2
0
 /**
  * @param \Google_Service_Datastore_PropertyReference|\Google_Service_Datastore_PropertyReference[]|string|string[] $property_or_properties
  * @return $this
  * @throws ParameterException
  */
 public function withGroupBy($property_or_properties)
 {
     if (!is_array($property_or_properties)) {
         $property_or_properties = [$property_or_properties];
     }
     foreach ($property_or_properties as $property) {
         if (is_string($property)) {
             $property = \DatastoreHelper::newPropertyReference($property);
         } else {
             if (!$property instanceof \Google_Service_Datastore_PropertyReference) {
                 throw new ParameterException(__METHOD__, ['string', \Google_Service_Datastore_PropertyReference::class]);
             }
         }
         $this->groupBys[] = $property;
     }
     return $this;
 }
 /**
  * @return \Google_Service_Datastore_Entity
  * @throws DatastoreHelperException
  */
 public function exportEntity()
 {
     if (empty($this->definedProperties)) {
         throw new DatastoreHelperException('No properties were defined in ' . self::class);
     }
     $entity = new \Google_Service_Datastore_Entity();
     if ($this->getKey() === null) {
         $entity->setKey($this->getKey());
     } else {
         $entity->setKey($this->getKey());
     }
     $properties = [];
     foreach ($this->definedProperties as $name => $spec) {
         $properties[$name] = \DatastoreHelper::newProperty($this->{$name}, $spec['type'], $spec['indexed']);
     }
     $entity->setProperties($properties);
     return $entity;
 }
Пример #4
0
 /**
  * @param string $propertyName
  * @param Direction|string $direction
  * @return Google_Service_Datastore_PropertyReference
  */
 public static function newPropertyOrder($propertyName, $direction = 'ASCENDING')
 {
     $order = new \Google_Service_Datastore_PropertyOrder();
     $order->setProperty(\DatastoreHelper::newPropertyReference($propertyName));
     $order->setDirection(Direction::get($direction)->value());
     return $order;
 }