コード例 #1
0
ファイル: Router.php プロジェクト: rakorium/okapi
 /**
  * @param string $route
  * @param array $params
  * @return Uri
  */
 public function assemble($route, $params = null, $base = null)
 {
     if ($base === null) {
         $request = $this->getRequest();
         if ($request) {
             $base = $request->getRoot();
         }
     }
     return $this->routes->assemble(Destination::match($params, $route), $base);
 }
コード例 #2
0
ファイル: ChainRouteTest.php プロジェクト: rakorium/okapi
 public function testSimple1()
 {
     $request = $this->request('admin/area/51');
     $root = $request->getRoot();
     $chain = Rt\ChainRoute::factory(['admin' => ['pattern' => '/admin', 'params' => ['controller' => 'C1', 'action' => 'a1'], 'children' => ['area' => ['pattern' => '/area[/{id}]', 'params' => ['extra' => 'EXTRA']]]]]);
     $exp = ['id' => '51', 'controller' => 'C1', 'action' => 'a1', 'extra' => 'EXTRA'];
     $dest = $chain->route($request);
     $this->assertTrue($dest->isMatch());
     $this->assertTrue($dest->isFinal());
     $this->assertEquals($exp, $dest->getParams()->core());
     $uri = $chain->assemble(Rt\Destination::match(['id' => 51], "admin/area"), $root);
     $this->assertEquals("{$root}/admin/area/51", $uri->toString());
 }