GDS\Mapper\ProtoBuf::configureGoogleKey PHP Method

configureGoogleKey() public method

Populate a ProtoBuf Key from a GDS Entity
public configureGoogleKey ( google\appengine\datastore\v4\Key $obj_key, Entity $obj_gds_entity ) : google\appengine\datastore\v4\Key
$obj_key google\appengine\datastore\v4\Key
$obj_gds_entity GDS\Entity
return google\appengine\datastore\v4\Key
    public function configureGoogleKey(Key $obj_key, Entity $obj_gds_entity)
    {
        // Add any ancestors FIRST
        $mix_ancestry = $obj_gds_entity->getAncestry();
        if (is_array($mix_ancestry)) {
            // @todo Get direction right!
            foreach ($mix_ancestry as $arr_ancestor_element) {
                $this->configureGoogleKeyPathElement($obj_key->addPathElement(), $arr_ancestor_element);
            }
        } elseif ($mix_ancestry instanceof Entity) {
            // Recursive
            $this->configureGoogleKey($obj_key, $mix_ancestry);
        }
        // Root Key (must be the last in the chain)
        $this->configureGoogleKeyPathElement($obj_key->addPathElement(), ['kind' => $obj_gds_entity->getKind(), 'id' => $obj_gds_entity->getKeyId(), 'name' => $obj_gds_entity->getKeyName()]);
        return $obj_key;
    }