/**
  * Get the full version of a namespace prefix
  *
  * Looks up a prefix (atom:, etc.) in the list of registered
  * namespaces and returns the full namespace URI if
  * available. Returns the prefix, unmodified, if it's not
  * registered.
  *
  * The current entry or feed's version will be used when performing the
  * namespace lookup unless overridden using $majorVersion and
  * $minorVersion. If the entry/fee has a null version, then the latest
  * protocol version will be used by default.
  *
  * @param string $prefix The namespace prefix to lookup.
  * @param integer $majorVersion The major protocol version in effect.
  *        Defaults to null (auto-select).
  * @param integer $minorVersion The minor protocol version in effect.
  *        Defaults to null (auto-select).
  * @return string
  */
 public function lookupNamespace($prefix, $majorVersion = null, $minorVersion = null)
 {
     // Auto-select current version
     if ($majorVersion === null) {
         $majorVersion = $this->getMajorProtocolVersion();
     }
     if ($minorVersion === null) {
         $minorVersion = $this->getMinorProtocolVersion();
     }
     // Perform lookup
     return parent::lookupNamespace($prefix, $majorVersion, $minorVersion);
 }
Exemplo n.º 2
0
 /**
  * Given a DOMNode representing an attribute, tries to map the data into
  * instance members.  If no mapping is defined, the name and value are
  * stored in an array.
  *
  * @param DOMNode $attribute The DOMNode attribute needed to be handled
  */
 protected function takeAttributeFromDOM($attribute)
 {
     switch ($attribute->localName) {
         case 'errorCode':
             $this->_errorCode = $attribute->nodeValue;
             break;
         case 'reason':
             $this->_reason = $attribute->nodeValue;
             break;
         case 'invalidInput':
             $this->_invalidInput = $attribute->nodeValue;
             break;
         default:
             parent::takeAttributeFromDOM($attribute);
     }
 }
Exemplo n.º 3
0
 public function testLookupNamespaceObeysParentBehavior()
 {
     $prefix = 'test';
     $testString10 = 'TEST-v1-0';
     $testString20 = 'TEST-v2-0';
     $testString11 = 'TEST-v1-1';
     $testString21 = 'TEST-v2-1';
     $testString12 = 'TEST-v1-2';
     $testString22 = 'TEST-v2-2';
     App\AbstractBase::flushNamespaceLookupCache();
     $feed = $this->feed;
     $feed->registerNamespace($prefix, $testString10, 1, 0);
     $feed->registerNamespace($prefix, $testString20, 2, 0);
     $feed->registerNamespace($prefix, $testString11, 1, 1);
     $feed->registerNamespace($prefix, $testString21, 2, 1);
     $feed->registerNamespace($prefix, $testString12, 1, 2);
     $feed->registerNamespace($prefix, $testString22, 2, 2);
     // Assumes default version (1)
     $result = $feed->lookupNamespace($prefix, 1, null);
     $this->assertEquals($testString12, $result);
     $result = $feed->lookupNamespace($prefix, 2, null);
     $this->assertEquals($testString22, $result);
     $result = $feed->lookupNamespace($prefix, 1, 1);
     $this->assertEquals($testString11, $result);
     $result = $feed->lookupNamespace($prefix, 2, 1);
     $this->assertEquals($testString21, $result);
     $result = $feed->lookupNamespace($prefix, null, null);
     $this->assertEquals($testString12, $result);
     $result = $feed->lookupNamespace($prefix, null, 1);
     $this->assertEquals($testString11, $result);
     // Override to retrieve latest version
     $feed->setMajorProtocolVersion(null);
     $result = $feed->lookupNamespace($prefix, null, null);
     $this->assertEquals($testString22, $result);
     $result = $feed->lookupNamespace($prefix, null, 1);
     $this->assertEquals($testString21, $result);
 }