/** * Returns all available to logged user BackendMenu items in yii\widgets\Menu acceptable format * @return BackendMenu[] Tree representation of items */ public static function getAllMenu() { $rows = Yii::$app->cache->get("BackendMenu:all"); if (false === is_array($rows)) { $rows = static::find()->orderBy('parent_id ASC, sort_order ASC')->asArray()->all(); Yii::$app->cache->set("BackendMenu:all", $rows, 86400, new TagDependency(['tags' => [\devgroup\TagDependencyHelper\ActiveRecordHelper::getCommonTag(static::className())]])); } // rebuild rows to tree $all_menu_items $all_menu_items = app\behaviors\Tree::rowsArrayToMenuTree($rows, 1, 1, false); return $all_menu_items; }