public function getRouteFromPathInfo(Request $request) {

		$application = Application::getInstance();
		$script = basename($request->getScriptName());

		if(!($path = trim($request->getPathInfo(), '/'))) {
			$pathSegments = [];
		}
		else {
			$pathSegments = explode('/' , $path);
		}

		// skip if pathinfo matches script name

		if(count($pathSegments) && $this->serverSideRewrite && basename($script, '.php') === $pathSegments[0]) {
			array_shift($pathSegments);
		}

		// when locale is found, set it as current locale in application and skip it

		if(count($pathSegments) && $application->hasLocale($pathSegments[0])) {
			$application->setCurrentLocale($application->getLocale($pathSegments[0]));
			array_shift($pathSegments);
		}

		// find route

        $route = $this->findRoute($pathSegments);

		// no route found

        if(!$route) {
            throw new ApplicationException(sprintf("No route found for path '%s'.", implode('/', $pathSegments)));
        }

		while(!$this->authenticateRoute($route)) {
            $route = $this->authenticator->handleViolation($route);
        }

		return $route;

	}
public function getRouteFromPathInfo(Request $request) {

		$application = Application::getInstance();
		$script = basename($request->getScriptName());

		if(!($path = trim($request->getPathInfo(), '/'))) {
			$pathSegments = [];
		}
		else {
			$pathSegments = explode('/' , $path);
		}

		// skip if pathinfo matches script name

		if(count($pathSegments) && $this->serverSideRewrite && basename($script, '.php') === $pathSegments[0]) {
			array_shift($pathSegments);
		}

		// when locale is found, set it as current locale in application and skip it

		if(count($pathSegments) && $application->hasLocale($pathSegments[0])) {
			$application->setCurrentLocale($application->getLocale($pathSegments[0]));
			array_shift($pathSegments);
		}

		// find route

        $route = $this->findRoute($pathSegments);

		// no route found

        if(!$route) {
            throw new ApplicationException(sprintf("No route found for path '%s'.", implode('/', $pathSegments)));
        }

		while(!$this->authenticateRoute($route)) {
            $route = $this->authenticator->handleViolation($route);
        }

		return $route;

	}
public function getRouteFromPathInfo ( Request $ request ) { $ application = Application :: getInstance ( ) ; $ script = basename ( $ request -> getScriptName ( ) ) ; if ( ! ( $ path = trim ( $ request -> getPathInfo ( ) , '/' ) ) ) { $ pathSegments = [ ] ; } else { $ pathSegments = explode ( '/' , $ path ) ; } // skip if pathinfo matches script name if ( count ( $ pathSegments ) && $ this -> serverSideRewrite && basename ( $ script , '.php' ) === $ pathSegments [ 0 ] ) { array_shift ( $ pathSegments ) ; } // when locale is found, set it as current locale in application and skip it if ( count ( $ pathSegments ) && $ application -> hasLocale ( $ pathSegments [ 0 ] ) ) { $ application -> setCurrentLocale ( $ application -> getLocale ( $ pathSegments [ 0 ] ) ) ; array_shift ( $ pathSegments ) ; } // find route $ route = $ this -> findRoute ( $ pathSegments ) ; // no route found if ( ! $ route ) { throw new ApplicationException ( sprintf ( "No route found for path '%s'." , implode ( '/' , $ pathSegments ) ) ) ; } while ( ! $ this -> authenticateRoute ( $ route ) ) { $ route = $ this -> authenticator -> handleViolation ( $ route ) ; } return $ route ; }
analyse path and return route associated with it
the first path fragment can be a locale string,
which is then skipped for determining the route

configured routes are first checked whether they fulfill the
request method and whether they match the path

if more than one route matches these requirements the one which
is more specific about the request method is preferred

if more than one route match the requirements and are equally
specific about the request methods the one with less
placeholders is preferred

if more than one match the requirements, are equally specific
about request methods and have the same number of placeholders
the one with more satisfied placeholders is preferred

@return \vxPHP\Routing\Route
@throws \vxPHP\Application\Exception\ApplicationException
analyse path and return route associated with it the first path fragment can be a locale string which is then skipped for determining the route