Auth_OpenID_AX_FetchResponse::getExtensionArgs PHP Метод

getExtensionArgs() публичный Метод

Serialize this object into arguments in the attribute exchange namespace
public getExtensionArgs ( $request = null )
    function getExtensionArgs($request = null)
    {
        $aliases = new Auth_OpenID_NamespaceMap();
        $zero_value_types = array();
        if ($request !== null) {
            // Validate the data in the context of the request (the
            // same attributes should be present in each, and the
            // counts in the response must be no more than the counts
            // in the request)
            foreach ($this->data as $type_uri => $unused) {
                if (!$request->contains($type_uri)) {
                    return new Auth_OpenID_AX_Error(sprintf("Response attribute not present in request: %s", $type_uri));
                }
            }
            foreach ($request->iterAttrs() as $attr_info) {
                // Copy the aliases from the request so that reading
                // the response in light of the request is easier
                if ($attr_info->alias === null) {
                    $aliases->add($attr_info->type_uri);
                } else {
                    $alias = $aliases->addAlias($attr_info->type_uri, $attr_info->alias);
                    if ($alias === null) {
                        return new Auth_OpenID_AX_Error(sprintf("Could not add alias %s for URI %s", $attr_info->alias, $attr_info->type_uri));
                    }
                }
                if (array_key_exists($attr_info->type_uri, $this->data)) {
                    $values = $this->data[$attr_info->type_uri];
                } else {
                    $values = array();
                    $zero_value_types[] = $attr_info;
                }
                if ($attr_info->count != Auth_OpenID_AX_UNLIMITED_VALUES && $attr_info->count < count($values)) {
                    return new Auth_OpenID_AX_Error(sprintf("More than the number of requested values " . "were specified for %s", $attr_info->type_uri));
                }
            }
        }
        $kv_args = $this->_getExtensionKVArgs($aliases);
        // Add the KV args into the response with the args that are
        // unique to the fetch_response
        $ax_args = $this->_newArgs();
        // For each requested attribute, put its type/alias and count
        // into the response even if no data were returned.
        foreach ($zero_value_types as $attr_info) {
            $alias = $aliases->getAlias($attr_info->type_uri);
            $kv_args['type.' . $alias] = $attr_info->type_uri;
            $kv_args['count.' . $alias] = '0';
        }
        $update_url = null;
        if ($request) {
            $update_url = $request->update_url;
        } else {
            $update_url = $this->update_url;
        }
        if ($update_url) {
            $ax_args['update_url'] = $update_url;
        }
        Auth_OpenID::update($ax_args, $kv_args);
        return $ax_args;
    }