getAllRoutes example

$connection = Database::getConnection();
    $provider = new RouteProvider($connection$this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');

    $this->fixtures->createTables($connection);

    $dumper = new MatcherDumper($connection$this->state, $this->logger, 'test_routes');
    $dumper->addRoutes($this->fixtures->SampleRouteCollection());
    $dumper->dump();

    $sample_routes = $this->fixtures->staticSampleRouteCollection();

    $returned_routes = $provider->getAllRoutes();

    $this->assertInstanceOf(\Iterator::class$returned_routes);
    $this->assertSameSize($sample_routes$returned_routes);

    foreach ($returned_routes as $route_name => $route) {
      $this->assertArrayHasKey($route_name$sample_routes);
      $this->assertEquals($route->getPath()$sample_routes[$route_name]['path']);
    }
  }

  /** * Confirms that a trailing slash on the request does not result in a 404. */
/** * {@inheritdoc} */
  public function getRoutesByPattern($pattern) {
    return $this->getRouteProvider()->getRoutesByPattern($pattern);
  }

  /** * {@inheritdoc} */
  public function getAllRoutes() {
    return $this->getRouteProvider()->getAllRoutes();
  }

  /** * {@inheritdoc} */
  public function reset() {
    // Don't call getRouteProvider as this is results in recursive rebuilds.     return $this->routeProvider->reset();
  }

  /** * Determines if the router has been rebuilt. * * @return bool * TRUE is the router has been rebuilt, FALSE if not. */
/** * {@inheritdoc} */
  public function routeProviderRouteCompare(array $a, array $b) {
    return $this->lazyLoadItself()->routeProviderRouteCompare($a$b);
  }

  /** * {@inheritdoc} */
  public function getAllRoutes() {
    return $this->lazyLoadItself()->getAllRoutes();
  }

  /** * {@inheritdoc} */
  public function reset() {
    return $this->lazyLoadItself()->reset();
  }

}
Home | Imprint | This part of the site doesn't use cookies.