Call any configured pre-route matching handler with first parsed word from
requested path and with request object to load for example from database
only routes you need to use for routing, not all of them.
@param string $firstPathWord
@return void
330971
protected function rewriteRoutingProcessPreHandler ($firstPathWord) {
		if ($this->preRouteMatchingHandler === NULL) return;
		call_user_func($this->preRouteMatchingHandler, $this, $this->request, $firstPathWord);
	}
412256
public function setFirstName($firstName)
    {
        if (!empty($firstName) && is_string($firstName) && ctype_print($firstName)) {
            $this->firstName = trim($firstName);
        }

        return $this;
    }
603872
protected function setStartLink($routeConfig)
    {
        if (empty($routeConfig['startLink']) && !empty($routeConfig['startLinkLabel'])) {
            $routeConfig['startLink'] = [
                'label' => $routeConfig['startLinkLabel'],
                'link'  => '', // default
            ];
        }
        if (!empty($routeConfig['startLink'])) {
            if (!empty($routeConfig['startLink']['action'])) {
                $action = '/' . $routeConfig['moduleUid'] . '/' . $routeConfig['startLink']['action'];
                $route = [$action];
                $url = Url::toRoute($action);
            } elseif (isset($routeConfig['startLink']['link'])) {
                $link = $routeConfig['startLink']['link'];
                $link = '/' . $routeConfig['urlPrefix']
                       . ( ($link == '' || $link == '?') ? '' : ('/' . $link) )
                       ;
                //$route = ??;
                $url = Url::toRoute($link);
            } else {
                throw new Exception("Insufficient 'link' or 'action' in 'startLink' paremeter of routeConfig");
            }
            
            $tcCat = TranslationsBuilder::getBaseTransCategory($this);
            $label = $routeConfig['startLink']['label'];
            $linkData = [
                'label' => $label,
                'tcCat' => $tcCat,
                'link'  => $url,
            ];
            if (isset($route)) $linkData['route'] = $route;

            static::$_startLinks[$this->uniqueId][$routeConfig['routesType']] = $linkData;
        }
    }
1080072
public function setPath(?string $path) : void
    {
        if (strpos($path, "/") !== 0) {
            $path = "/" . $path;
        }
        $this->path = $path;
    }
92139
public function setFirstResult($firstResult)
    {
        $this->_firstResult = $firstResult;
        $this->_state       = self::STATE_DIRTY;

        return $this;
    }
829343
public function reroute($path) {

        if (strpos($path,'://') === false) {
            if (substr($path,0,1)!='/'){
                $path = '/'.$path;
            }
            $path = $this->routeUrl($path);
        }

        header('Location: '.$path);
        $this->stop();
    }
700413
protected function prepareLink(string &$link = null): void
	{
		if ($link !== null) {
			if (Strings::endsWith($link, ':default')) {
				$link = substr($link, 0, -7);
			}
			$pos = strrpos($link, ':');
			if ($pos !== strlen($link)) {
				$link = substr($link, 0, $pos + 1);
			}
		}
	}
692429
public function run( string $routesFilename=''  )
  {
    #
    # Load the Routes
    #
    if ( empty($routesFilename) ) {
      $routesFilename = $this->getBasePath().'/app/Config/routes.json';
    }
    $this->loadRoutes( $routesFilename );


    # Get Method and URI
    $httpMethod = $this->getRequest()->getMethod();
    $path = $this->getRequest()->getUri()->getPath();
    $routeInfo = null;

    # Find route match in groups
    foreach ($this->getRouteGroups() as $routeGroup)
    {
      # Match the METHOD and URI to the routes in this group
      $routeInfo = $routeGroup->matchRoute($httpMethod,$path);

      if ( count($routeInfo)>0 ) {
        $beforeResult = true; // assume all before handlers succeed
        $routeResult = false;
        $afterResult = true; // assume all after handlers succeed

        # Debug log
        $this->getLogger()->debug('Route matched ',['handler'=>$routeInfo['handler']]);

        #
        # Run the Common AND Groups Before Middlewares (ServerRequestInterface)
        #
        $beforeMiddleware = array_merge($this->beforeMiddleware, $routeGroup->getBeforeMiddleware());

        foreach ($beforeMiddleware as $middleware)
        {
          if (class_exists($middleware) ) {
            $beforeHandler = new $middleware($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Running Before middleware',['rid'=>app('requestId'),'middleware'=>$middleware]);

            if (!$beforeHandler->handle($routeInfo['args'])) {
              # Record outcome
              $beforeResult = false;
              # Stop processing more middleware
              break;
            }
          } else {
            # Log
            $this->getLogger()->warning('Before Middleware not found',['rid'=>app('requestId'),'middleware'=>$middleware]);
          }
        }

        #
        # Create & Run the Handler Class - If the Before Middlewares where ok!
        #
        if ($beforeResult) {
          # Extract class & method
          $arr = explode('@',$routeInfo['handler']);
          $handlerClass = $arr[0];
          $handlerMethod = ($arr[1] ?? 'handle');

          # Check existance of handler class
          if (class_exists($handlerClass))
          {
            # Create the class
            $routeHandler = new $handlerClass( $routeInfo['args'] );

            # Check method existance
            if ($routeHandler && method_exists($routeHandler,'initialize') && method_exists($routeHandler,$handlerMethod))
            {
              # Debug log
              $this->getLogger()->debug('Running controller->initialize()',['rid'=>app('requestId'),'controller'=>$handlerClass]);

              # Initialize
              $routeHandler->initialize($routeInfo['args']);

              # Debug log
              $this->getLogger()->debug('Running controller->handle()',['rid'=>app('requestId'),'method'=>$handlerMethod]);

              # Run handler
              $routeResult = $routeHandler->$handlerMethod($routeInfo['args']);
            } else {
              # Log
              $this->getLogger()->error('Method not found in controller ',['rid'=>app('requestId'),'controller'=>$handlerClass,'method'=>$handlerMethod]);
            }
          } else {
            # Debug log
            $this->getLogger()->debug('Controller not found ',['rid'=>app('requestId'),'controller'=>$handlerClass]);
          }
        }

        #
        # Run the After Middlewares (ServerRequestInterface)
        #
        $afterMiddleware = array_merge($this->afterMiddleware,$routeGroup->getAfterMiddleware());
        foreach ($afterMiddleware as $middleware)
        {
          if (class_exists($middleware) ) {
            $afterHandler = new $middleware($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Running After middleware',['rid'=>app('requestId'),'middleware'=>$middleware]);

            if (!$afterHandler->handle($routeInfo['args'])) {
              return false;
            }
          } else {
            # Log
            $this->getLogger()->warning('After Middleware not found',['rid'=>app('requestId'),'middleware'=>$middleware]);
          }
        }

        return $routeResult;

      } else {
        # No route matched the URI in this group, we'll look in the next group or exit the foreach()
        $routeInfo = null;
      }

    }

    # Output debug info
    if (is_null($routeInfo)) {
      # Debug log
      $this->getLogger()->debug('No route matched request',['rid'=>app('requestId'),'method'=>$httpMethod,'path'=>$path]);
    }

    return false; // default response
  }
42724
public function onBefore(BeforeEvent $event)
    {
        $request = $event->getRequest();
        $context = Tracer::spanContext();
        if ($context->enabled()) {
            $request->setHeader($this->propagator->key(), $this->propagator->formatter()->serialize($context));
        }
        $span = Tracer::startSpan([
            'name' => 'GuzzleHttp::request',
            'attributes' => [
                'method' => $request->getMethod(),
                'uri' => $request->getUrl()
            ],
            'kind' => Span::KIND_CLIENT
        ]);
        $this->scope = Tracer::withSpan($span);
    }
706227
public static function route() :void {

		// marker
		Profiler::setMarker('Router.route', 'framework');
		// get the requested url
		$request_url = Request::getUrl();
		// get the requested method
		$request_method = Request::getMethod();
		// Loop over each route and test to see if they are valid
		foreach(self::$_routes as $route) {
			// if the route matches
			if(self::routeMatch($request_url, $request_method, $route)) {
				// get it
				$matching_route = $route;
				// stop trying
				break;
			}
		}
		// marker
		Profiler::releaseMarker('Router.route');
		// if no match is found and we don't have an error route to fallback on
		if(!isset($matching_route)) {
			// throw a native exception since there is no cleaner alternative
			Throw new Exception('Router::route() no matching route', 404);
		}
		// send the matching route to the dispatcher
		self::forward($matching_route);	
		
	}
611199
public function prependRoutingInformation(array $routing)
    {
        $count = count($routing);
        if (0 == $count) {
            return;
        }

        // Strip all the empty parts from the last to the first.
        $count--;
        while (!$routing[$count]) {
            unset($routing[$count]);
            $count--;
        }

        // Make sure the last part is always empty.
        $routing[] = '';

        // Prepend the routing and add a routing delimiter (empty part).
        $this->routing = array_merge($routing, $this->routing);
    }
987428
public function setFirst($first)
    {
        if (Format::isIdentifier($first)) {
            $this->first = $first;
        } else {
            $msg = "'${first}' is an invalid QTI identifier.";
            throw new InvalidArgumentException($msg);
        }
    }
909499
protected function pathMatchesSearch($path, $words)
    {
        $path = Str::lower($path);

        foreach ($words as $word) {
            $word = trim($word);
            if (!strlen($word)) {
                continue;
            }

            if (!Str::contains($path, $word)) {
                return false;
            }
        }

        return true;
    }
70224
private function checkLinesBeforeFirstUse(int $firstUsePos): void
    {
        $posBeforeFirstUse = TokenHelper::findPreviousExcluding($this->getFile(), T_WHITESPACE, $firstUsePos - 1);
        $realLinesBeforeUse = $this->getRealLinesBeforeFirstUse($firstUsePos, $posBeforeFirstUse);

        if ($realLinesBeforeUse !== self::LINES_BEFORE_FIRST_USE) {
            $fix = $this->getFile()->addFixableError(
                self::MESSAGE_INCORRECT_LINES_COUNT_BEFORE_FIRST_USE,
                $firstUsePos,
                self::CODE_INCORRECT_LINES_COUNT_BEFORE_FIRST_USE,
                [
                    self::LINES_BEFORE_FIRST_USE,
                    $realLinesBeforeUse
                ]
            );

            if ($fix) {
                $this->fixLinesBeforeFirstUse($firstUsePos, $posBeforeFirstUse, self::LINES_BEFORE_FIRST_USE);
            }
        }
    }
426391
protected function load(string $path): void
    {
        $namespace = $this->app->getNamespace();

        /** @var SplFileInfo[] $files */
        $files = (new Finder)->in($path)->files();

        foreach ($files as $file) {
            $file = $namespace.str_replace(
                    ['/', '.php'],
                    ['\\', ''],
                    Str::after($file->getPathname(), app_path().DIRECTORY_SEPARATOR)
                );

            if (is_subclass_of($file, Intent::class) && !(new ReflectionClass($file))->isAbstract()) {
                $this->app['conversation']->registerIntent($file);
            }
        }
    }
1129218
private function jumpToFirstChild()
    {
        $eg_node = $this->getNode();
        if (isset($eg_node['!a']['class'])
            || sizeof($this->URL->getParamsAsArray())
            || !isset($eg_node['!c']['url'])
        ) {
            return;
        }

        foreach ($eg_node['!c']['url'] as $v) {
            PWELogger::info('Jump To First Сhild: %s', $v['!a']['link']);
            $jumpTo = $v['!a']['link'];

            if ($this->URL->isForcedTrailingSlash()) {
                $jumpTo .= '/';
            } else {
                $jumpTo = implode('/', $this->URL->getMatchedAsArray()) . '/' . $jumpTo;
            }

            if (isset($_SERVER["QUERY_STRING"]) && strlen($_SERVER["QUERY_STRING"])) {
                $jumpTo .= '?' . $_SERVER["QUERY_STRING"];
            }

            throw new HTTP3xxException($jumpTo, HTTP3xxException::REDIRECT);
        }
    }
88117
public function routePages($page_prefix)
    {
        if ($this->app instanceof App_Frontend) {
            /** @type App_Frontend $this->app */
            $this->app->routePages($page_prefix, $this->namespace);
        }
    }