Example #1
0
 public function testMatchRequestFalse()
 {
     $urlBag = new UrlBag();
     $routes = $this->fileLoader->load(__DIR__ . "/fixtures/no_pattern.ini");
     $router = new Router($routes);
     $this->assertFalse($router->matchRequest($urlBag));
 }
Example #2
0
 /**
  * Start the framework MVC engine
  *
  * @param ErrorHandlerWrapperInterface $errorHandlerWrapper
  *
  * @throws LoadConfigFileException
  * @throws RouteNotFoundException
  */
 public function mvcHandle(ErrorHandlerWrapperInterface $errorHandlerWrapper)
 {
     if (null !== $this->router) {
         return;
     }
     ErrorHandler::init($errorHandlerWrapper, $this->logsDir);
     if (false === $this->configLoaded) {
         throw new LoadConfigFileException(sprintf('Please call "%s" before call "%s"', __CLASS__ . "::loadConfig", __METHOD__));
     }
     $this->router = new Router($this->getRoutes());
     // match current request
     if (false === ($matches = $this->router->matchRequest($this->urlBag))) {
         throw new RouteNotFoundException(sprintf('No route found for "%s"', $this->getUrl()));
     }
     $this->route = $matches["route"];
     $this->controller = $matches["controller"];
     $this->action = $matches["action"];
     $this->params = $matches["params"];
     print $this->renderController("{$this->getController()}:{$this->getAction()}", $this->getParams());
 }