コード例 #1
0
 /**
  * @Rest\Put("/{id}/author",
  *  condition="request.headers.get('content-type') matches '/domain-model=add-author/i'",
  *  requirements={
  *      "id"="[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}"
  *  },
  *  defaults={
  *      "id"=null
  *  }
  * )
  * @Rest\View()
  *
  * @ParamConverter("id",
  *  class="AppBundle\EventSourcing\EventStore\Uuid",
  *  converter="param_converter"
  * )
  * @ParamConverter("author",
  *  class="AppBundle\Controller\Resource\Book\Author",
  *  converter="fos_rest.request_body"
  * )
  * @ParamConverter("version",
  *  class="AppBundle\Domain\ReadModel\Book",
  *  options={
  *      "id": "id",
  *  },
  *  converter="param_converter"
  * )
  *
  * @param Uuid $id
  * @param AuthorResource $author
  * @param integer $version
  * @return View
  * @throws HttpException
  */
 public function addAuthorAction(Uuid $id, AuthorResource $author, $version)
 {
     $command = new AddAuthor($id, $author->getFirstName(), $author->getLastName(), $version);
     $this->commandBus->send($command);
     $updatedBook = $this->bookService->getBook($id);
     return $this->viewBuilder->setDocument($updatedBook)->setVersion()->setLocation(static::BASE_ROUTE . $updatedBook->getId())->build();
 }