Skip to content

Instantly share code, notes, and snippets.

@crisu83
Last active December 13, 2015 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crisu83/4990837 to your computer and use it in GitHub Desktop.
Save crisu83/4990837 to your computer and use it in GitHub Desktop.
Random recursive method.
<?php
public function buildMenuRecursive($parentID = 0) {
$result = array();
$menus = Menus::model()->getMenusUsuarios($parentID);
foreach ($menus as $key => $value) {
$result[$key] = array(
'name' => $value['title'],
'link' => $value['url'] ? Yii::app()->createUrl($value['url']) : '',
'visible' => $value['status'],
'icon' => $value['icon'],
'sub' => $this->buildMenuRecursive($value['id']),
);
}
return $result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment