本文整理汇总了PHP中grade_category::_get_children_recursion方法的典型用法代码示例。如果您正苦于以下问题:PHP grade_category::_get_children_recursion方法的具体用法?PHP grade_category::_get_children_recursion怎么用?PHP grade_category::_get_children_recursion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类grade_category
的用法示例。
在下文中一共展示了grade_category::_get_children_recursion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _get_children_recursion
/**
* Private method used to retrieve all children of this category recursively
*
* @param grade_category $category Source of current recursion
* @return array An array of child grade categories
*/
private static function _get_children_recursion($category)
{
$children_array = array();
foreach ($category->children as $sortorder => $child) {
if (array_key_exists('itemtype', $child)) {
$grade_item = new grade_item($child, false);
if (in_array($grade_item->itemtype, array('course', 'category'))) {
$type = $grade_item->itemtype . 'item';
$depth = $category->depth;
} else {
$type = 'item';
$depth = $category->depth;
// we use this to set the same colour
}
$children_array[$sortorder] = array('object' => $grade_item, 'type' => $type, 'depth' => $depth);
} else {
$children = grade_category::_get_children_recursion($child);
$grade_category = new grade_category($child, false);
if (empty($children)) {
$children = array();
}
$children_array[$sortorder] = array('object' => $grade_category, 'type' => 'category', 'depth' => $grade_category->depth, 'children' => $children);
}
}
// sort the array
ksort($children_array);
return $children_array;
}