/**
  * Generate a Response object for the given {$template}
  * @param string $template
  * @param array $data
  * @return \Psr\Http\Message\ResponseInterface
  */
 protected function view($template, $data = [])
 {
     try {
         return $this->app->view->render($this->app->response, $template, $this->getTemplateData($data));
     } catch (\Twig_Error $e) {
         $this->app->notFound();
     }
 }
 protected function viewXml($template, $data = [])
 {
     try {
         $response = $this->container->response->withHeader('Content-type', 'text/xml');
         return $this->container->view->render($response, $template, $this->getTemplateData($data));
     } catch (\Twig_Error $e) {
         $this->app->notFound();
     }
 }