public function testPriority()
 {
     $endPoint = new Point\ControllerPoint(['controller' => 'DemoController', 'action' => 'action']);
     $this->routes->add('default', new Route('/blog/', $endPoint), 70);
     $this->routes->add('cats', new Route('/cats/', $endPoint), 50);
     $this->routes->add('profile', new Route('/cats/', $endPoint), 60);
     $routes = $this->routes->getRoutes();
     self::assertEquals(['default', 'profile', 'cats'], array_keys($routes));
 }
Ejemplo n.º 2
0
 /**
  * @param CollectionRoute $routes
  * @param string $path
  * @param null|string $method
  * @param null|bool $isXHR
  * @return \Generator
  * @throws NotFoundException
  */
 public function match(CollectionRoute $routes, $path, $method = null, $isXHR = null)
 {
     $find = 0;
     foreach ($routes->getRoutes() as $route) {
         $point = $this->matchRoute($route, $path, $method, $isXHR);
         if ($point) {
             $find++;
             (yield $point);
         }
     }
     if (!$find) {
         throw new NotFoundException('Not found');
     }
 }