Ejemplo n.º 1
0
 /**
  * Map variable access onto the underlying entry representation.
  *
  * Get-style access returns a Zend_Feed_Element representing the
  * child element accessed. To get string values, use method syntax
  * with the __call() overriding.
  *
  * @param  string $var The property to access.
  * @return mixed
  */
 public function __get($var)
 {
     $nodes = $this->_children($var);
     $length = count($nodes);
     if ($length == 1) {
         return new Zend_Feed_Element($nodes[0]);
     } elseif ($length > 1) {
         return array_map(create_function('$e', 'return new Zend_Feed_Element($e);'), $nodes);
     } else {
         // When creating anonymous nodes for __set chaining, don't
         // call appendChild() on them. Instead we pass the current
         // element to them as an extra reference; the child is
         // then responsible for appending itself when it is
         // actually set. This way "if ($foo->bar)" doesn't create
         // a phantom "bar" element in our tree.
         if (strpos($var, ':') !== false) {
             list($ns, $elt) = explode(':', $var, 2);
             $node = $this->_element->ownerDocument->createElementNS(Zend_Feed::lookupNamespace($ns), $elt);
         } else {
             $node = $this->_element->ownerDocument->createElement($var);
         }
         $node = new Zend_Feed_Element($node);
         $node->setParent($this);
         return $node;
     }
 }