/** * Translate an Entity to a datastore representation. * * @param Entity $entity The input entity. * @return array A Datastore [Entity](https://cloud.google.com/datastore/reference/rest/v1/Entity) */ public function objectToRequest(Entity $entity) { $data = $entity->get(); $properties = []; foreach ($data as $key => $value) { $exclude = in_array($key, $entity->excludedProperties()); $meaning = isset($entity->meanings()[$key]) ? $entity->meanings()[$key] : null; $properties[$key] = $this->valueObject($value, $exclude, $meaning); } return array_filter(['key' => $entity->key(), 'properties' => $properties]); }