public function testGet()
 {
     $route = new TestAsset\DummyRoute();
     $this->list->insert('foo', $route, 0);
     $this->assertEquals($route, $this->list->get('foo'));
     $this->assertNull($this->list->get('bar'));
 }
Beispiel #2
0
 /**
  * assemble(): defined by RouteInterface interface.
  *
  * @see    Route::assemble()
  * @param  array $params
  * @param  array $options
  * @return mixed
  * @throws Exception\InvalidArgumentException
  * @throws Exception\RuntimeException
  */
 public function assemble(array $params = array(), array $options = array())
 {
     if (!isset($options['name'])) {
         throw new Exception\InvalidArgumentException('Missing "name" option');
     }
     $route = $this->routes->get($options['name']);
     if (!$route) {
         throw new Exception\RuntimeException(sprintf('Route with name "%s" not found', $options['name']));
     }
     unset($options['name']);
     return $route->assemble(array_merge($this->defaultParams, $params), $options);
 }
Beispiel #3
0
 /**
  * Get an extra route which does not belong to current section;
  * If the extra routes stack is not loaded,
  * load them from route registry cache
  *
  * @param string $name
  * @return RouteInterface|null
  */
 protected function extraRoute($name)
 {
     if (null == $this->routesExtra) {
         $this->routesExtra = new PriorityList();
         $extraConfig = (array) Pi::registry('route')->read(Pi::engine()->section(), true);
         foreach ($extraConfig as $key => $options) {
             $route = $this->routeFromArray($options);
             $priority = isset($route->priority) ? $route->priority : null;
             $this->routesExtra->insert($key, $route, $priority);
         }
     }
     return $this->routesExtra->get($name);
 }