Auth_OpenID_SRegBase::_getSRegNS PHP Method

_getSRegNS() static public method

$message: The OpenID message from which to parse simple registration fields. This may be a request or response message. Returns the sreg namespace URI for the supplied message. The message may be modified to define a simple registration namespace.
static public _getSRegNS ( $message )
    static function _getSRegNS($message)
    {
        $alias = null;
        $found_ns_uri = null;
        // See if there exists an alias for one of the two defined
        // simple registration types.
        foreach (array(Auth_OpenID_SREG_NS_URI_1_1, Auth_OpenID_SREG_NS_URI_1_0) as $sreg_ns_uri) {
            $alias = $message->namespaces->getAlias($sreg_ns_uri);
            if ($alias !== null) {
                $found_ns_uri = $sreg_ns_uri;
                break;
            }
        }
        if ($alias === null) {
            // There is no alias for either of the types, so try to
            // add one. We default to using the modern value (1.1)
            $found_ns_uri = Auth_OpenID_SREG_NS_URI_1_1;
            if ($message->namespaces->addAlias(Auth_OpenID_SREG_NS_URI_1_1, 'sreg') === null) {
                // An alias for the string 'sreg' already exists, but
                // it's defined for something other than simple
                // registration
                return null;
            }
        }
        return $found_ns_uri;
    }

Usage Example

Example #1
0
 function test_openID2Defined_1_0()
 {
     $this->msg->namespaces->add(Auth_OpenID_SREG_NS_URI_1_0);
     $ns_uri = Auth_OpenID_SRegBase::_getSRegNS($this->msg);
     $this->assertEquals(Auth_OpenID_SREG_NS_URI_1_0, $ns_uri);
 }
Auth_OpenID_SRegBase