function createKeyForTestItem() { $path = new Google_Service_Datastore_KeyPathElement(); $path->setKind("URLLinks"); $key = new Google_Service_Datastore_Key(); $key->setPath([$path]); return $key; }
public function createKey() { $key = new \Google_Service_Datastore_Key(); if (isset($this->config['namespace'])) { $partition = new \Google_Service_Datastore_PartitionId(); $partition->setNamespace($this->config['namespace']); $key->setPartitionId($partition); } return $key; }
/** * @param \Google_Service_Datastore_Key $key * @return \Google_Service_Datastore_KeyPathElement */ public static function getLastPath($key) { $path = $key->getPath(); return $path[count($path) - 1]; }
/** * 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; }
protected function createKey($id = null) { $key = new \Google_Service_Datastore_Key(['path' => [['kind' => 'Book']]]); // If we have an ID, set it in the path if ($id) { $key->getPath()[0]->setId($id); } return $key; }
/** * @param \Google_Service_Datastore_Key $key * @return Builder */ public static function fromKey($key) { $keyBuilder = new self(); $keyBuilder->parent = $key->getPath(); /** @var \Google_Service_Datastore_KeyPathElement $latestPath */ $latestPath = array_pop($keyBuilder->parent); $keyBuilder->kind = $latestPath->getKind(); $keyBuilder->id = $latestPath->getId(); $keyBuilder->name = $latestPath->getName(); return $keyBuilder; }
/** * 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; }