security->isGranted('ROLE_USER')) { throw new AccessDeniedHttpException(); } $address->setRefStatus(Address::ADDR_REFERENCE_STATUS_REVIEWED); $this->entityManager->flush(); return new JsonResponse( $this->serializer->serialize($address, 'json', [AbstractNormalizer::GROUPS => ['read']]), JsonResponse::HTTP_OK, [], true ); } /** * Set an address back to "to review". Only if the address is in "reviewed" state. * * @Route("/api/1.0/main/address/reference-match/{id}/set/to_review", methods={"POST"}) */ public function markAddressAsToReview(Address $address): JsonResponse { if (!$this->security->isGranted('ROLE_USER')) { throw new AccessDeniedHttpException(); } if (Address::ADDR_REFERENCE_STATUS_REVIEWED !== $address->getRefStatus()) { throw new AccessDeniedHttpException("forbidden to mark a matching address to 'to review'"); } $address->setRefStatus(Address::ADDR_REFERENCE_STATUS_TO_REVIEW); $this->entityManager->flush(); return new JsonResponse( $this->serializer->serialize($address, 'json', [AbstractNormalizer::GROUPS => ['read']]), JsonResponse::HTTP_OK, [], true ); } /** * @Route("/api/1.0/main/address/reference-match/{id}/sync-with-reference", methods={"POST"}) */ public function syncAddressWithReference(Address $address): JsonResponse { if (null === $address->getAddressReference()) { throw new BadRequestHttpException('this address does not have any address reference'); } $address->syncWithReference($address->getAddressReference()); $this->entityManager->flush(); return new JsonResponse( $this->serializer->serialize($address, 'json', [AbstractNormalizer::GROUPS => ['read']]), JsonResponse::HTTP_OK, [], true ); } }