Пример #1
0
function createKeyForTestItem()
{
    $path = new Google_Service_Datastore_KeyPathElement();
    $path->setKind("URLLinks");
    $key = new Google_Service_Datastore_Key();
    $key->setPath([$path]);
    return $key;
}
 /**
  * Fetch 1-many Entities, using the Key parts provided
  *
  * @param array $arr_key_parts
  * @param $str_setter
  * @return mixed
  */
 protected function fetchByKeyPart(array $arr_key_parts, $str_setter)
 {
     $arr_keys = [];
     foreach ($arr_key_parts as $str_key_part) {
         $obj_key = new \Google_Service_Datastore_Key();
         $obj_element = new \Google_Service_Datastore_KeyPathElement();
         $obj_element->setKind($this->obj_schema->getKind());
         $obj_element->{$str_setter}($str_key_part);
         $obj_key->setPath([$obj_element]);
         $arr_keys[] = $obj_key;
     }
     // Build, run & map the request
     return $this->fetchByKeys($arr_keys);
 }
 /**
  * Fetches a unique key from Datastore
  */
 public function createUniqueKeyRequest()
 {
     // retrieve a unique ID from datastore
     $path = new \Google_Service_Datastore_KeyPathElement();
     $path->setKind(self::KIND);
     $key = new \Google_Service_Datastore_Key();
     $key->setPath([$path]);
     $idRequest = new \Google_Service_Datastore_AllocateIdsRequest();
     $idRequest->setKeys([$key]);
     return $idRequest;
 }
Пример #4
0
 /**
  * @return \Google_Service_Datastore_Key
  * @throws MissingFieldsException
  */
 public function build()
 {
     $partitionId = new \Google_Service_Datastore_PartitionId();
     $partitionId->setDatasetId($this->datasetId);
     $partitionId->setNamespace($this->namespace);
     $key = new \Google_Service_Datastore_Key();
     $key->setPartitionId($partitionId);
     $key->setPath($this->getPath());
     return $key;
 }
 /**
  * Create a Google Entity Key from a GDS Entity, with a Kind any any existing key data
  *
  * @param Entity $obj_gds_entity
  * @return \Google_Service_Datastore_Key
  */
 public function createKey(Entity $obj_gds_entity)
 {
     $obj_key = new \Google_Service_Datastore_Key();
     $obj_key->setPath($this->buildKeyPath($obj_gds_entity));
     return $obj_key;
 }