本文整理匯總了PHP中BaseObject::getChildren方法的典型用法代碼示例。如果您正苦於以下問題:PHP BaseObject::getChildren方法的具體用法?PHP BaseObject::getChildren怎麽用?PHP BaseObject::getChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類BaseObject
的用法示例。
在下文中一共展示了BaseObject::getChildren方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _objectToJson
/**
* Internal helper function to get node with children.
*
* @param \BaseObject $instance
* @return array
*/
protected function _objectToJson(\BaseObject $instance)
{
$nodes = $this->lazy ? $instance->getChildren($this->query) : $instance->getDescendants($this->query);
if ($nodes instanceof \PropelCollection) {
$nodes = $nodes->getArrayCopy();
}
array_unshift($nodes, $instance);
$level = array();
foreach ($nodes as $node) {
$p = call_user_func($this->nodeCallback, $node, $this, $node->getTreeLevel());
$level[$node->getLevel()] =& $p;
if (isset($level[$node->getLevel() - 1])) {
$level[$node->getLevel() - 1]['children'][] =& $p;
}
unset($p);
}
return $level[$instance->getLevel()];
}
示例2: deleteChildren
/**
* Deletes given node direct children.
*
* @param BaseObject $node
*/
public function deleteChildren(BaseObject $node)
{
// array_reverse() call is necessary for root node properties to be correctly updated
foreach (array_reverse($node->getChildren()) as $child) {
$child->delete();
}
}