本文整理匯總了PHP中Zend_Feed_Element::setParent方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Feed_Element::setParent方法的具體用法?PHP Zend_Feed_Element::setParent怎麽用?PHP Zend_Feed_Element::setParent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend_Feed_Element
的用法示例。
在下文中一共展示了Zend_Feed_Element::setParent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __get
/**
* 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;
}
}