Exemplo n.º 1
0
 /**
  * @Post("/")
  *
  * @return Response
  */
 public function addAction()
 {
     $bookData = $this->request->getJsonRawBody();
     $book = new Book();
     $book->setName($bookData->name);
     $book->setDescription($bookData->description);
     $response = new Response();
     if ($book->save() === true) {
         $response->setStatusCode(201, "Created");
         $response->setJsonContent(['status' => 'OK', 'data' => $book->getId()]);
     } else {
         $this->createErrorResponse($response, $book);
     }
     return $response;
 }