Пример #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);
     }
 }
Пример #2
0
 /**
  * @expectedException \UnexpectedValueException
  */
 public function testWrongCallbackClassType()
 {
     $locationFinder = new CallbackMethod(function ($request, $context) {
         $context->set(Context::KEY_SOURCE, 'PSX\\Loader\\ProbeController::doIndex');
         return $request;
     });
     $controller = new \stdClass();
     $resolver = $this->getMock('PSX\\Loader\\CallbackResolverInterface');
     $resolver->method('resolve')->will($this->returnValue($controller));
     $loader = new Loader($locationFinder, $resolver, Environment::getService('event_dispatcher'), new Logger('psx', [new NullHandler()]));
     $request = new Request(new Url('http://127.0.0.1/foobar'), 'GET');
     $response = new Response();
     $loader->load($request, $response);
 }