Initialize Routes

@return MVC
@throws \LogicException
965975
final protected function initRoutes()
    {
        $routes = $this->setRoutes();
        foreach ($routes as $currentRoutes) {
            foreach ($currentRoutes as $route) {
                $this->container->addRoute($route);
            }
        }
        
        return $this;
    }
205822
protected function loadRouting()
    {
        $parser = new YamlParser();
        $routes = array();
        foreach ($this->getRoutingFiles() as $file) {
            $routes = array_merge($routes, $parser->parse(file_get_contents($file)));
        }

        foreach ($routes as $name => $routeInfos) {
            $this->processRouteInfos($name, $routeInfos);
        }

        return $this;
    }
583795
public function init()
    {
        $this->routes = $this->routes->getRouteCollections();

        $this->dispatcher = $this->createDispatcher();

        $this->currentURL = $this->request->getPathInfo();

        $this->dispatch();
    }
494687
public function create()
    {
        $pdo = null;
        try {
            $pdo = $this->connect();
        } catch (\Exception $e) {
            $pdo = null;
            if ($this->isLostConnection($e)) {
                $pdo = $this->reconnect();
            }

            throw new \LogicException('Connection lost and no reconnector available.');
        }

        return $pdo;
    }
792414
public static function start() {
    	$controller = (self::$route->module).'Controller';
    	$view = (self::$route->module).'View';
    	$model = (self::$route->module).'Model';
        $action = (self::$route->action).'Action';

        $module_root = MODULES_ROOT.'/'.self::$route->module;

        switch (true) {
			case (file_exists($module_root) &&
				 file_exists($module_root."/$model.php") &&
				 file_exists($module_root."/$view.php") &&
				 file_exists($module_root."/$controller.php")):
				$namespace = self::$route->module;

				if (class_exists("Module\\$namespace\\$controller")) {
					$app_controller = "Module\\$namespace\\$controller";
					$AppController = new $app_controller();
				} else {
					throw MvcException::UndefinedModule(self::$route->module);
				}

				if (method_exists($AppController, $action)) { $content = $AppController->$action(); } else {
					throw MvcException::UndefinedMethodInController($action, get_class($AppController));
				}
				break;

			default: throw MvcException::UndefinedModule(self::$route->module); break;
		}

        self::setContent($content);
    }
1196188
protected function processRequest()
    {
        $route  = $this[ 'request' ]->getRoute();
        $params = $this[ 'request' ]->getParams();

        $controller = $this[ 'router' ]->createController( $route, $params );

        if ( NULL === $controller )
        {
            throw new RawException( 'Failed to Initialise Controller', 404 );
        }

        $this->controller = $controller;

        /** @var IController $controller */
        $controller->run();
    }
366581
public function initialize()
    {
        $this->setSource($this->tableName);
        $this->belongsTo('route_id', __NAMESPACE__ . '\Route', 'id', array('alias' => 'Route'));
        $this->belongsTo('navigation_id', __NAMESPACE__ . '\Navigation', 'id', array('alias' => 'Navigation'));
    }
1107647
public function loadRoutes()
    {
        $routeFiles = $this->config["routeFiles"];
        foreach ($routeFiles as $file) {
            $this->loadFile($file, ["app" => $this]);
        }
        return $this;
    }
490341
private function loadRouteRules()
    {
        foreach ($this->rules['routeRules'] as $routeAlias => $routeRuleSets) {
            $resourceId = call_user_func_array($this->config['routeResourceGenerator'], [$routeAlias]);
            $this->acl->addResource(new Resource($resourceId));
            foreach ($routeRuleSets as $ruleSet) {
                $this->enforceRuleset($ruleSet, ['resources' => $resourceId, 'privileges' => $this->config['routePrivilege']]);
            }
        }
    }
1206824
protected function mapRoute(): Controller
    {
        foreach ($this->routes['get'] as $pattern => $func) {
            $this->mapStaticRoutes($pattern, $func);
        }

        foreach ($this->routes['post'] as $pattern => $func) {
            $this->mapStaticRoutes($pattern, $func, 'post');
        }

        return $this;
    }
880245
protected function loadRoutes() : void
    {
        $routeConfig = Core::i()->config->getConfiguration('routes');
        // If there is a default route, make it last in the array
        if (isset($routeConfig['default'])) {
            $default_route = $routeConfig['default'];
            unset($routeConfig['default']);
            $routeConfig['default'] = $default_route;
        }
        // Parse the routes and build the regex strings
        foreach ($routeConfig as $route_name => $route) {
            $regex = $route['route'];
            $regex = str_replace('/', '\/', $regex);
            $regex = str_replace('[', '(', $regex);
            $regex = str_replace(']', ')?', $regex);
            if (isset($route['constraints'])) {
                foreach ($route['constraints'] as $key => $constraint) {
                    $regex = str_replace(':' . $key . ':', "(?P<{$key}>" . $constraint . ')', $regex);
                }
            }
            $routeConfig[$route_name]['regex'] = '/^' . $regex . '$/i';
        }
        $this->route_definitions = $routeConfig;
    }
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;
    }
273746
protected function routeSetUpSelfRouteNameIfAny () {
		/** @var $this \MvcCore\Router */
		if ($this->currentRoute instanceof \MvcCore\IRoute) 
			$this->selfRouteName = $this->anyRoutesConfigured
				? $this->currentRoute->GetName()
				: $this->currentRoute->GetControllerAction();
		return $this;
	}
910847
protected function initializeControllerContext()
    {

        $request = new ActionRequest(Request::createFromEnvironment());
        $request->setDispatched(true);
        if (isset($this->flowHttpSettings['baseUri'])) {
            $request->getHttpRequest()->setBaseUri(new Uri($this->flowHttpSettings['baseUri']));
        }

        $response = new Response();

        $uriBuilder = new UriBuilder();
        $uriBuilder->setRequest($request);

        $arguments = new Arguments(array());

        $this->controllerContext = new ControllerContext($request, $response, $arguments, $uriBuilder);
    }
295159
private function init()
    {
        // Set the layout from the Config file
        $this->layout = View::make(config('decoy.core.layout'));

        // Store the controller class for routing
        $this->controller = get_class($this);

        // Get the controller name
        $controller_name = $this->controllerName($this->controller);

        // Make a default title based on the controller name
        if (empty($this->title)) {
            $this->title = $this->title($controller_name);
        }

        // Figure out what the show view should be.  This is the path to the show
        // view file.  Such as 'admin.news.edit'
        if (empty($this->show_view)) {
            $this->show_view = $this->detailPath($this->controller);
        }

        // Try to suss out the model by singularizing the controller
        if (empty($this->model)) {
            $this->model = $this->model($this->controller);
            if (!class_exists($this->model)) {
                $this->model = null;
            }
        }

        // If the input contains info on the parent, immediately instantiate
        // the parent instance.  These are populated by some AJAX calls like
        // autocomplete on a many to many and the attach method.
        if (($parent_id = request('parent_id'))
            && ($parent_controller = request('parent_controller'))) {
            $parent_model_class = $this->model($parent_controller);
            $this->parent($parent_model_class::findOrFail($parent_id));
        }
    }
186995
public function prepareForSerialization()
	{
		if ( $this->action['uses'] instanceof Closure )
			throw new LogicException( "Unable to prepare route [{$this->uri}] for serialization. Uses Closure." );

		unset( $this->router, $this->bindings, $this->compiled );
	}
149120
function init() {
		config = app.config;

		defaultController = config.defaultControllerFactory(app.models);

		// load controllers
		var controllerDir = path.join(config.rootDir, config.paths.controllers);
		var controllerFiles = fs.readdirSync(controllerDir);
		controllerFiles.forEach(function(controllerFile) {
			var controllerName = controllerFile.substring(0, controllerFile.indexOf('Controller'));
			var controllerDef = require(path.join(controllerDir, controllerFile));
			var controller;
			if (controllerDef.noDefaultActions) {
				controller = controllerDef;
			} else {
				controller = Object.create(defaultController);
				controller = Object.merge(controller, controllerDef);
			}
			app.controllers[controllerName] = controller;
		});

		applyPathPolicies();

		var routes = config.routes,
			parsed = [];

		parseResourceRoutes();

		for (var route in routes) {
			parsed.push(parseRoute(route, routes[route]));
		}

		parsed.forEach(function(route) {
			if(!route.target)
				return;

			if (Object.isString(route.target)) {
				if (route.verbs[0] !== 'static' && route.target.charAt(0) === '/') {
					route.target = {redirect: route.target};
				} else {
					var parts = route.target.split('.');
					if (parts.length === 2) {
						route.target = {controller: parts[0], action: parts[1]};
					}
				}
			}
			if (!Object.isObject(route.target)) {
				route.target = {controller: route.target};
			}

			route.verbs.forEach(function (verb) {
				if (verb === 'resource') {
					addResourceRoute(route.path, route.target.controller);
				} else if (verb === 'static') {
					addStaticRoute(route.path, route.target.controller);
				} else if (route.target.redirect) {
					addRedirectRoute(verb, route.path, route.target.redirect);
				} else {
					addSingleRoute(verb, route.path, route.target.controller, route.target.action);
				}
			});
		});

		if(config.autoRoute) {
			resourceRouting.forEach(function(route) {
				var actionPath = path.join('/', config.autoRoutePath, route.path);
				route.verbs.forEach(function (verb) {
					app[verb](actionPath, function(req, res, next) {
						var controllerName = req.params.controller.singularize();
						var actionName = route.target.action;
						req.controller = controllerName;
						req.action = actionName;

						var action = getAction(controllerName, actionName);
						if (action) {
							var policies = getPolicies(controllerName, actionName);
							if (policies.length > 0) {
								var policyIdx = 0;
								var nextPolicy = function() {
									policyIdx++;
									if (policyIdx < policies.length) {
										policies[policyIdx](req, res, nextPolicy);
									} else {
										action(req, res, next);
									}
								};
								policies[0](req, res, nextPolicy);
							} else {
								action(req, res, next);
							}
						} else {
							next();
						}
					});
				});
			});
		}
	}