Assign routes

@return array
427760
public function actionAssign(): array
    {
        $routes = Yii::$app->getRequest()->post('routes', []);
        $model = Yii::createObject($this->modelClass);
        $model->addNew($routes);

        return $model->getAvailableAndAssignedRoutes();
    }
1071982
protected function getRoutes()
    {
        if (0 === count($this->routes)) {
            return $this->router->getRouteCollection()->all();
        }

        $routes = [];
        foreach ($this->routes as $name) {
            $route = $this->router->getRouteCollection()->get($name);
            if (null !== $route) {
                $routes[$name] = $route;
            }
        }

        return $routes;
    }
386962
public function getRoutes()
    {
        $manager = Yii::$app->getAuthManager();
        $routes = $this->getAppRoutes();
        $exists = [];
        foreach (array_keys($manager->getPermissions()) as $name) {
            if ($name[0] !== '/') {
                continue;
            }
            $exists[] = $name;
            unset($routes[$name]);
        }
        return [
            'avaliable' => array_keys($routes),
            'assigned' => $exists
        ];
    }
830809
public function map()
    {
        Route::namespace($this->namespace)->group(function (Router $router) {
            /*
             * Admin routes
             */
            $router->middleware('admin')->prefix('admin')->group(function (Router $router) {
                $router->get('translations', 'AdminController@index')->name('admin::index-translations')->middleware('can:see-all-translations');
                $router->get('translations/create', 'AdminController@create')->name('admin::create-translation')->middleware('can:create-translation');
                $router->get('translations/{translation}/edit', 'AdminController@edit')->name('admin::edit-translation')->middleware('can:update-translation');
                $router->post('translations', 'AdminController@store')->name('admin::store-translation')->middleware('can:create-translation');
                $router->put('translations/{translation}', 'AdminController@update')->name('admin::update-translation')->middleware('can:update-translation');
            });

            /*
             * API routes
             */
            $router->middleware('api')->prefix('api')->group(function (Router $router) {
                $router->middleware('auth:api')->group(function (Router $router) {
                    $router->get('translations', 'ApiController@index')->middleware('can:see-all-translations');
                    $router->patch('translations/{translation}', 'ApiController@updatePartial')->middleware('can:update-translation');
                    $router->delete('translations/{translation}', 'ApiController@destroy')->middleware('can:delete-translation');
                });
            });
        });
    }
566489
public function map() {
		$modules = Module::all();
		
		//dd($modules);
		
		foreach ($modules as $module) {
			$routes = $module->routes;
			$routesFolder = 'routes'.DIRECTORY_SEPARATOR;
			
			if ($routes) {
				foreach ($routes as $route) {
					if (strrpos($route, $routesFolder."web")) {
						
						$this->mapWebRoute($route, $module->namespace);
					}
					elseif (strrpos($route, $routesFolder."api")) {
						
						$this->mapApiRoute($route, $module->namespace);
					}
				}
			}
		}
	}
170776
protected function mapRoutes()
    {
        if (!$this->app->routesAreCached()) {
            Route::group(
                ['middleware' => ['web']], function () {
                    $routes = new Routes();

                    // Backend Routes
                    $routes->mapBackendRoutes()
                        ->mapPluginsBackendRoutes();

                    // Frontend Routes
                    $routes->mapFrontendBaseRoutes()
                        ->mapFrontendRoutes()
                        ->mapThemeRoutes()
                        ->mapPluginsFrontendRoutes();

                    // Add Language {lang} prefix
                    $routes->addLanguagePrefix()
                        ->sortRoutes();
                }
            );
        }
    }
1269187
public function setRoutes()
    {
        $routesJsonFile = $this->getAppDir() . '/config/routes.json';
        $routesPhpFile = $this->getAppDir() . '/config/routes.php';
        $routes = array();

        if (file_exists($routesJsonFile)) {
            $routes[] = json_decode(file_get_contents($routesJsonFile), true);
        } elseif (file_exists($routesPhpFile)) {
            $routes[] = require_once $routesPhpFile;
        }

        foreach ($this->container->getModules() as $module) {
            $extension = $module->getModuleExtension();
            if (is_object($extension) && $extension instanceof Injection\Extension) {
                $routes[] = $extension->loadRoutes();
            }
        }

        return $routes;
    }
802931
public function setRoutes() : void
    {
        if (is_null($this->routes)) {
            $this->routes = [];
            $routesConfig = $this->config->getParam('routes') ?? [];
            foreach ($routesConfig as $routeName => $routeArr) {
                $route = new Route(
                    $routeName,
                    $routeArr['methods'],
                    $routeArr['path'],
                    $routeArr['params_defaults'],
                    $routeArr['params_requirements'],
                    $routeArr['handler'],
                    $routeArr['handler_method'] ?? null
                );
                $this->routes[] = $route;
            }
        }
    }
126280
private function get_route_parts() : array {
		$to = $this->routes[ $this->__method_name ]['to'];
		if ( \is_array( $to ) ) {
			$to_parts = $to;
		} else {
			$to_parts = explode( '@', $to );
		}

		$to_class  = $to_parts[0];
		$to_method = $to_parts[1];

		$on_error = null;
		if ( array_key_exists( 'on_error', $this->routes[ $this->__method_name ] ) ) {
			$on_error = $this->routes[ $this->__method_name ]['on_error'];
		}

		return [ $to_class, $to_method, $on_error ];
	}
1001840
protected function addRoutes()
    {
		return ["Route::delete('" . $this->routeName . "/arr-delete', '" . $this->controller . "@arrDelete')->name('" . $this->myAddrName . ".arrDelete');\nRoute::resource('" . $this->routeName . "', '" . $this->controller . "');"];
    }
1065319
public function actionAssign()
    {
        $post = Yii::$app->getRequest()->post();
        $action = $post['action'];
        $routes = $post['routes'];
        $manager = Yii::$app->getAuthManager();
        $error = [];
        if ($action == 'assign') {
            $this->saveNew($routes);
        } else {
            foreach ($routes as $route) {
                $child = $manager->getPermission($route);
                try {
                    $manager->remove($child);
                } catch (Exception $exc) {
                    $error[] = $exc->getMessage();
                }
            }
        }
        Helper::invalidate();
        Yii::$app->getResponse()->format = 'json';
        return array_merge($this->getRoutes(), ['errors' => $error]);
    }
758991
private function setRoutes() : void
    {
        $this->routes = $this->routeProvider->getRoutes();
        $this->syRouteCollection = new RouteCollection();
        foreach ($this->routes as $route) {
            $syRoute = new SymfonyRoute(
                $route->getPath(),
                $route->getParamsDefaults(),
                $route->getParamsRequirements(),
                [],
                '',
                [],
                $route->getMethods()
            );
            $this->syRouteCollection->add($route->getName(), $syRoute);
        }
    }
1184387
public static function ApiRoutes(){
        Route::group(['prefix' => 'geo'], function(){
            Route::get('search/{name}/{parent_id?}',    '\Igaster\LaravelCities\GeoController@search');
            Route::get('item/{id}',         '\Igaster\LaravelCities\GeoController@item');
            Route::get('items/{ids}',       '\Igaster\LaravelCities\GeoController@items');
            Route::get('children/{id}',     '\Igaster\LaravelCities\GeoController@children');
            Route::get('parent/{id}',       '\Igaster\LaravelCities\GeoController@parent');
            Route::get('country/{code}',    '\Igaster\LaravelCities\GeoController@country');
            Route::get('countries',         '\Igaster\LaravelCities\GeoController@countries');
        });
    }
74526
public function setupRoutes()
    {
        if ($this->routeManager === null) {
            parent::setupRoutes();

            // Serve the Admin's "Not Found" handler for the Admin's route group.
            $this->app()->any('{catchall:.*}', 'notFoundHandler');
        }

        return $this;
    }
466052
private function generateDeclaredRoutes()
    {
        $routes = "array(\n";
        foreach ($this->getRoutes()->all() as $name => $route) {
            $compiledRoute = $route->compile();

            $properties = array();
            $properties[] = $compiledRoute->getVariables();
            $properties[] = $route->getDefaults();
            $properties[] = $route->getRequirements();
            $properties[] = $compiledRoute->getTokens();
            $properties[] = $compiledRoute->getHostTokens();
            $properties[] = $route->getSchemes();

            $routes .= sprintf("        '%s' => %s,\n", $name, str_replace("\n", '', var_export($properties, true)));
        }
        $routes .= '    )';

        return $routes;
    }
611096
public function getAllRoutes(): array
  {
    foreach ($this->routesGet as $rout)
    {
      $this->routesAll[] = $rout;
    }

    foreach ($this->routesPost as $rout)
    {
      $this->routesAll[] = $rout;
    }

    return $this->routesAll;
  }
1121056
public static function routes()
  {
    Route::group(['namespace' => 'Auth'], function () {

      Route::group(['middleware' => ['guest']], function () {

        Route::get('login', 'LoginController@showLoginPage')->name('showLogin');
        Route::post('login', 'LoginController@login')->name('login');

        Route::get('login/email', 'LoginController@showMagicLinkPage')->name('showMagicLink');
        Route::post('login/email', 'LoginController@loginWithEmail')->name('loginWithEmail');
        Route::get('login/callback/email/', 'LoginController@loginEmailCallback')->name('loginCallback');

        Route::get('register', 'RegisterController@showRegistrationPage')->name('showRegistration');
        Route::post('register', 'RegisterController@register')->name('register');

        Route::get('password/forgot', 'ForgotPasswordController@showForgotPasswordPage')->name('showForgotPassword');
        Route::post('password/forgot', 'ForgotPasswordController@forgot')->name('forgot');

        Route::get('password/reset', 'ForgotPasswordController@showResetPasswordPage')->name('showResetPassword');
        Route::post('password/reset', 'ForgotPasswordController@resetPassword')->name('resetPassword');

      });

      Route::get('logout', 'LoginController@logout')->name('logout')->middleware('private', 'auth');
      Route::get('account/verify', 'RegisterController@verifyEmail')->name('verify');

    });
  }