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;
 }
 /**
  * Apply the current namespace to an object or array of objects
  *
  * @param $mix_target
  * @return mixed
  */
 private function applyNamespace($mix_target)
 {
     if (null !== $this->str_namespace) {
         $obj_partition = new \Google_Service_Datastore_PartitionId();
         $obj_partition->setNamespace($this->str_namespace);
         if (is_array($mix_target)) {
             foreach ($mix_target as $obj_target) {
                 $obj_target->setPartitionId($obj_partition);
             }
         } else {
             $mix_target->setPartitionId($obj_partition);
         }
     }
     return $mix_target;
 }
 /**
  * @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;
 }