本文整理汇总了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();
}
}