コード例 #1
0
 /**
  * @param \Exception $e
  *
  * @return \Symfony\Component\HttpFoundation\Response
  *
  * @throws \Exception
  */
 public function getErrorResponse(\Exception $e)
 {
     if (config('app.debug')) {
         throw $e;
     }
     return parent::getErrorResponse($e);
 }
コード例 #2
0
 public function testItCanGetWillReturnErrorResponse()
 {
     $callable = function () {
         throw new \Exception();
     };
     $response = $this->resource->get(10, $this->data, Post::class, $callable, $this->updateCallable);
     $this->assertInstanceOf(Response::class, $response);
     $this->assertEquals(400, $response->getStatusCode());
 }
コード例 #3
0
 /**
  * @param Request $request
  * @param         $id
  *
  * @return Response
  */
 protected function patchAction(Request $request, $id)
 {
     $find = $this->findResourceCallable($id);
     $update = $this->updateResourceCallable();
     $resource = new PatchResource($this->serializer);
     return $this->addHeaders($resource->get($id, (array) $request->get('data'), get_class($this->getDataModel()), $find, $update));
 }
コード例 #4
0
 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function patchAction(Request $request)
 {
     $resource = new PatchResource($this->serializer);
     $response = $resource->get($request->id, (array) $request->get('data'), get_class($this->getDataModel()), $this->findResourceCallable($request), $this->updateResourceCallable());
     return $this->addHeaders($response);
 }