getRequest() public method

Get the request
public getRequest ( ) : Psr\Http\Message\RequestInterface
return Psr\Http\Message\RequestInterface
 public function testGetters()
 {
     $event = new ApiExceptionEvent(new Exception(), new Request('GET', 'http://mockservice.com/get'));
     $this->assertInstanceOf(Exception::class, $event->getException());
     $this->assertInstanceOf(Request::class, $event->getRequest());
 }
Example #2
0
 /**
  * Log an api exception with the request
  *
  * @param ApiExceptionEvent $event
  */
 public function onApiException(ApiExceptionEvent $event)
 {
     $request = $event->getRequest();
     $exception = $event->getException();
     $this->logger->error('Request Exception', ['request' => ['method' => $request->getMethod(), 'uri' => rawurldecode((string) $request->getUri()), 'headers' => $request->getHeaders(), 'body' => (string) $request->getBody()], 'exception' => $exception]);
 }