Example #1
0
 private function reformatLocationHeader(ResponseInterface $response)
 {
     $location = $response->getHeader('Location');
     if ($location && !preg_match('/^http[s]?:\\/\\//', $location)) {
         $response->setHeader('Location', $this->config->getConfig('site_protocol') . '://' . $this->config->getConfig('site_domain') . $location);
     }
 }
 function getMessage(ResponseInterface $response, RequestInterface $request)
 {
     $methodName = 'get' . $response->getStatus() . 'Message';
     if (!method_exists($this, $methodName)) {
         return false;
     }
     return $this->getSummary($response) . call_user_func_array(array($this, $methodName), array($response, $request));
 }
 function filterResponse(ResponseInterface $response)
 {
     $printer = $this->getPrinter($this->getOutputType($response->getHeader('Content-Type')));
     $this->addDebugExecutionTime();
     $this->addDebugMemoryUsage();
     $response->setContent($printer->printDebug($this->debug, $response->getContent()));
     return $response;
 }
 function renderFor($resource_name, ResponseInterface $response, RequestInterface $request)
 {
     $templates = $this->package_provider->getTemplatesFor($resource_name, $request);
     if (!$templates['template'] instanceof TemplateInterface) {
         $response->setStatus(406);
     } else {
         $response->setContent($this->renderer->renderTemplate($templates['template'], $response->getContent(), $templates['layout']));
         $response->setHeader('Content-Type', $templates['mime-type']);
     }
     return $response;
 }