コード例 #1
0
 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);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
ファイル: SimpleRouteStack.php プロジェクト: nieldm/zf2
 /**
  * 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);
 }
コード例 #4
0
ファイル: TreeRouteStack.php プロジェクト: Andyyang1981/pi
 /**
  * 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);
 }