public function actionRegister()
 {
     $model = new AuthItem();
     if (Yii::$app->request->isPost) {
         $routes = Yii::$app->request->post('routes');
         if (!empty($routes) && is_array($routes)) {
             $auth = Yii::$app->authManager;
             foreach ($routes as $route) {
                 $oldPermission = $auth->getPermission($route);
                 if (empty($oldPermission)) {
                     $role = $auth->createPermission($route);
                     $auth->add($role);
                 }
             }
             Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Your data route(s) has been successfully saved'));
             return $this->redirect(['register']);
         } else {
             Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Your data route(s) failed to save'));
         }
     }
     $routers = RouterGenerator::run();
     ksort($routers);
     $registeredRouters = AuthItem::find()->where(['like', 'name', '/'])->andWhere(['type' => 2])->all();
     return $this->render('create-existing', ['model' => $model, 'routers' => $routers, 'registeredRouters' => $registeredRouters]);
 }
 public static function run()
 {
     $modules = Yii::$app;
     $router = new RouterGenerator();
     return $router->getAllModules($modules);
 }