Beispiel #1
0
 /**
  * addRoute(): defined by RouteStack interface.
  *
  * @see    Route::addRoute()
  * @param  string  $name
  * @param  mixed   $route
  * @param  integer $priority
  * @return RouteStack
  */
 public function addRoute($name, $route, $priority = null)
 {
     if (!$route instanceof Route) {
         $route = $this->routeFromArray($route);
     }
     $this->routes->insert($name, $route, $priority);
     return $this;
 }
 public function testLIFOWithPriority()
 {
     $this->list->insert('foo', new TestAsset\DummyRoute(), 0);
     $this->list->insert('bar', new TestAsset\DummyRoute(), 0);
     $this->list->insert('baz', new TestAsset\DummyRoute(), 1);
     $order = array();
     foreach ($this->list as $key => $value) {
         $orders[] = $key;
     }
     $this->assertEquals(array('baz', 'bar', 'foo'), $orders);
 }
Beispiel #3
0
 /**
  * addRoute(): defined by RouteStackInterface interface.
  *
  * @see    RouteStack::addRoute()
  * @param  string  $name
  * @param  mixed   $route
  * @param  integer $priority
  * @return SimpleRouteStack
  */
 public function addRoute($name, $route, $priority = null)
 {
     if (!$route instanceof RouteInterface) {
         $route = $this->routeFromArray($route);
     }
     if ($priority === null && isset($route->priority)) {
         $priority = $route->priority;
     }
     $this->routes->insert($name, $route, $priority);
     return $this;
 }
 public function testPriorityWithNegativesAndNull()
 {
     $this->list->insert('foo', new TestAsset\DummyRoute(), null);
     $this->list->insert('bar', new TestAsset\DummyRoute(), 1);
     $this->list->insert('baz', new TestAsset\DummyRoute(), -1);
     $order = array();
     foreach ($this->list as $key => $value) {
         $orders[] = $key;
     }
     $this->assertEquals(array('bar', 'foo', 'baz'), $orders);
 }
Beispiel #5
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);
 }