Inheritance: extends League\BooBoo\Formatter\AbstractFormatter, use trait Phprest\Service\Hateoas\Getter, use trait Phprest\Service\Hateoas\Util
Example #1
0
 public function testFormatWithNotAcceptable()
 {
     $request = Request::createFromGlobals();
     $request->headers->set('Accept', 'yaml');
     $jsonXmlFormatter = new JsonXml($this->config, $request);
     $this->assertContains('"code":0,"message":"Not Acceptable","details":["yaml is not supported"]', $jsonXmlFormatter->format(new \Exception()));
 }
Example #2
0
 /**
  * @return void
  */
 protected function setErrorHandler()
 {
     $app = $this;
     $this->configuration->getLogHandler()->setLogger($this->serviceLogger());
     $this->configuration->getErrorHandler()->pushHandler($this->configuration->getLogHandler());
     $this->configuration->getErrorHandler()->register();
     $this->setExceptionDecorator(function (\Exception $e) use($app) {
         $formatter = new ErrorHandler\Formatter\JsonXml($app->configuration);
         return new Response($formatter->format($e), http_response_code());
     });
 }