Ejemplo n.º 1
0
 /**
  * Forwards the request to another controller
  *
  * @param string $source
  * @param array $parameters
  */
 protected function forward($source, array $parameters = array())
 {
     $path = $this->reverseRouter->getPath($source, $parameters);
     if ($path !== null) {
         $this->request->setUri($this->request->getUri()->withPath($path));
         $this->loader->load($this->request, $this->response, $this->context);
     } else {
         throw new RuntimeException('Could not find route for source ' . $source);
     }
 }
Ejemplo n.º 2
0
 public function testGetPath()
 {
     $routingFile = new RoutingFile('tests/PSX/Loader/routes');
     $router = new ReverseRouter($routingFile, 'http://foo.com', '');
     $this->assertEquals('/foo/bar', $router->getPath('PSX\\Loader\\Foo2Controller'));
     $routingFile = new RoutingFile('tests/PSX/Loader/routes');
     $router = new ReverseRouter($routingFile, 'http://foo.com/foo/bar', '');
     $this->assertEquals('/foo/bar', $router->getPath('PSX\\Loader\\Foo2Controller'));
     $routingFile = new RoutingFile('tests/PSX/Loader/routes');
     $router = new ReverseRouter($routingFile, 'http://foo.com/foo/bar', 'index.php/');
     $this->assertEquals('/foo/bar', $router->getPath('PSX\\Loader\\Foo2Controller'));
     $routingFile = new RoutingFile('tests/PSX/Loader/routes');
     $router = new ReverseRouter($routingFile, 'http://foo.com', '');
     $this->assertEquals('http://cdn.foo.com/files/foo/common.js', $router->getPath('PSX\\Loader\\Foo13Controller', array('path' => 'foo/common.js')));
 }