Exemplo n.º 1
0
 private function routeRequest(Request $request, Service $service)
 {
     $desired_method = String::underscoreToCamelCase($request->getMethod());
     $requested_method = $request->getRequestMethod() . $desired_method;
     $method = $requested_method;
     $arguments = $request->getArguments();
     if (!method_exists($service, $method)) {
         $method = $request->getRequestMethod() . 'Router';
         if (!method_exists($service, $method)) {
             throw new MethodNotSupported($request->getService(), $requested_method);
         }
         array_splice($arguments, 0, 0, array($request->getMethod()));
     }
     $output = call_user_func_array(array($service, $method), $arguments);
     $this->response->setResponse($output);
 }
Exemplo n.º 2
0
 public function testEchoResponse()
 {
     $output = null;
     $this->response->addEventHandler(Response::OUTPUT_EVENT, function (Response $response) use(&$output) {
         $output = $response->getResponse();
     });
     $this->response->setResponseType(Response::TEXT);
     $this->response->echoResponse('Hello World');
     $this->assertSame('Hello World', $output);
 }