Note that if you store two routes with the same name, the first route will be overwritten.
Inheritance: use trait Webiny\Component\StdLib\StdLibTrait
Example #1
0
 /**
  * Builds and returns RouteCollection instance.
  *
  * @return RouteCollection
  */
 public function getRouteCollection()
 {
     foreach ($this->config as $name => $routeConfig) {
         $this->routeCollection->add($name, $this->processRoute($routeConfig));
     }
     unset($this->config);
     return $this->routeCollection;
 }
Example #2
0
 /**
  * Adds a route to the beginning of the current route collection.
  *
  * @param ConfigObject $routes An instance of ConfigObject holding the routes.
  *
  * @return $this
  */
 public function prependRoutes(ConfigObject $routes)
 {
     foreach ($routes as $name => $routeConfig) {
         self::$routeCollection->prepend($name, $this->loader->processRoute($routeConfig));
     }
     return $this;
 }