mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
replace BadRequestException by BadRequestHttpException
This commit is contained in:
parent
f14c915502
commit
48daed26f9
@ -16,9 +16,9 @@ use Chill\MainBundle\Serializer\Model\Collection;
|
|||||||
use Exception;
|
use Exception;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use RuntimeException;
|
use RuntimeException;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
@ -55,7 +55,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
return $this->entityDelete('_entity', $request, $id, $_format);
|
return $this->entityDelete('_entity', $request, $id, $_format);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \Symfony\Component\HttpFoundation\Exception\BadRequestException('This method is not implemented');
|
throw new BadRequestHttpException('This method is not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,7 +120,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
return $this->entityPostAction('_entity', $request, $_format);
|
return $this->entityPostAction('_entity', $request, $_format);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new \Symfony\Component\HttpFoundation\Exception\BadRequestException('This method is not implemented');
|
throw new BadRequestHttpException('This method is not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
try {
|
try {
|
||||||
$entity = $this->deserialize($action, $request, $_format, $entity);
|
$entity = $this->deserialize($action, $request, $_format, $entity);
|
||||||
} catch (NotEncodableValueException $e) {
|
} catch (NotEncodableValueException $e) {
|
||||||
throw new BadRequestException('invalid json', 400, $e);
|
throw new BadRequestHttpException('invalid json', 400, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = $this->validate($action, $request, $_format, $entity);
|
$errors = $this->validate($action, $request, $_format, $entity);
|
||||||
@ -273,7 +273,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
try {
|
try {
|
||||||
$postedData = $this->getSerializer()->deserialize($request->getContent(), $postedDataType, $_format, $postedDataContext);
|
$postedData = $this->getSerializer()->deserialize($request->getContent(), $postedDataType, $_format, $postedDataContext);
|
||||||
} catch (\Symfony\Component\Serializer\Exception\UnexpectedValueException $e) {
|
} catch (\Symfony\Component\Serializer\Exception\UnexpectedValueException $e) {
|
||||||
throw new BadRequestException(sprintf('Unable to deserialize posted ' .
|
throw new BadRequestHttpException(sprintf('Unable to deserialize posted ' .
|
||||||
'data: %s', $e->getMessage()), 0, $e);
|
'data: %s', $e->getMessage()), 0, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new BadRequestException('this method is not supported');
|
throw new BadRequestHttpException('this method is not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = $this->validate($action, $request, $_format, $entity, [$postedData]);
|
$errors = $this->validate($action, $request, $_format, $entity, [$postedData]);
|
||||||
@ -408,7 +408,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
return $this->json($entity, Response::HTTP_OK, [], $context);
|
return $this->json($entity, Response::HTTP_OK, [], $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Symfony\Component\HttpFoundation\Exception\BadRequestException('This format is not implemented');
|
throw new BadRequestHttpException('This format is not implemented');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function entityPostAction($action, Request $request, string $_format): Response
|
protected function entityPostAction($action, Request $request, string $_format): Response
|
||||||
@ -418,7 +418,7 @@ class ApiController extends AbstractCRUDController
|
|||||||
try {
|
try {
|
||||||
$entity = $this->deserialize($action, $request, $_format, $entity);
|
$entity = $this->deserialize($action, $request, $_format, $entity);
|
||||||
} catch (NotEncodableValueException $e) {
|
} catch (NotEncodableValueException $e) {
|
||||||
throw new BadRequestException('invalid json', 400, $e);
|
throw new BadRequestHttpException('invalid json', 400, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = $this->validate($action, $request, $_format, $entity);
|
$errors = $this->validate($action, $request, $_format, $entity);
|
||||||
|
@ -25,6 +25,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
|||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Security\Core\Role\Role;
|
use Symfony\Component\Security\Core\Role\Role;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
@ -1140,6 +1141,6 @@ class CRUDController extends AbstractController
|
|||||||
return $this->json($entity, Response::HTTP_OK, [], $context);
|
return $this->json($entity, Response::HTTP_OK, [], $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Symfony\Component\HttpFoundation\Exception\BadRequestException('This format is not implemented');
|
throw new BadRequestHttpException('This format is not implemented');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ use Chill\MainBundle\Search\UnknowSearchNameException;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
@ -216,7 +215,7 @@ class SearchController extends AbstractController
|
|||||||
$types = $request->query->get('type', []);
|
$types = $request->query->get('type', []);
|
||||||
|
|
||||||
if (count($types) === 0) {
|
if (count($types) === 0) {
|
||||||
throw new BadRequestException('The request must contains at '
|
throw new BadRequestHttpException('The request must contains at '
|
||||||
. ' one type');
|
. ' one type');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ use Doctrine\ORM\EntityManagerInterface;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
@ -144,7 +143,7 @@ class WorkflowController extends AbstractController
|
|||||||
public function getAccessByAccessKey(EntityWorkflowStep $entityWorkflowStep, Request $request): Response
|
public function getAccessByAccessKey(EntityWorkflowStep $entityWorkflowStep, Request $request): Response
|
||||||
{
|
{
|
||||||
if (null === $accessKey = $request->query->get('accessKey', null)) {
|
if (null === $accessKey = $request->query->get('accessKey', null)) {
|
||||||
throw new BadRequestException('accessKey is missing');
|
throw new BadRequestHttpException('accessKey is missing');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->getUser() instanceof User) {
|
if (!$this->getUser() instanceof User) {
|
||||||
|
@ -33,10 +33,10 @@ use DateInterval;
|
|||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
|
||||||
use Symfony\Component\Serializer\Exception\RuntimeException;
|
use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||||
@ -185,7 +185,7 @@ final class AccompanyingCourseApiController extends ApiController
|
|||||||
->deserialize($request->getContent(), Person::class, $_format, []);
|
->deserialize($request->getContent(), Person::class, $_format, []);
|
||||||
|
|
||||||
if (null === $person) {
|
if (null === $person) {
|
||||||
throw new BadRequestException('person id not found');
|
throw new BadRequestHttpException('person id not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO add acl
|
// TODO add acl
|
||||||
@ -204,7 +204,7 @@ final class AccompanyingCourseApiController extends ApiController
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new BadRequestException('This method is not supported');
|
throw new BadRequestHttpException('This method is not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = $this->validator->validate($accompanyingPeriod);
|
$errors = $this->validator->validate($accompanyingPeriod);
|
||||||
@ -247,12 +247,12 @@ final class AccompanyingCourseApiController extends ApiController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null === $requestor) {
|
if (null === $requestor) {
|
||||||
throw new BadRequestException('Could not find any person or thirdparty', 0, null);
|
throw new BadRequestHttpException('Could not find any person or thirdparty', 0, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
$accompanyingPeriod->setRequestor($requestor);
|
$accompanyingPeriod->setRequestor($requestor);
|
||||||
} else {
|
} else {
|
||||||
throw new BadRequestException('method not supported');
|
throw new BadRequestHttpException('method not supported');
|
||||||
}
|
}
|
||||||
|
|
||||||
$errors = $this->validator->validate($accompanyingPeriod);
|
$errors = $this->validator->validate($accompanyingPeriod);
|
||||||
|
@ -21,9 +21,9 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
|||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\Validator\ConstraintViolationInterface;
|
use Symfony\Component\Validator\ConstraintViolationInterface;
|
||||||
@ -255,7 +255,7 @@ class AccompanyingCourseController extends Controller
|
|||||||
$personIds = $request->query->get('person_id');
|
$personIds = $request->query->get('person_id');
|
||||||
|
|
||||||
if (false === is_array($personIds)) {
|
if (false === is_array($personIds)) {
|
||||||
throw new BadRequestException('person_id parameter should be an array');
|
throw new BadRequestHttpException('person_id parameter should be an array');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($personIds as $personId) {
|
foreach ($personIds as $personId) {
|
||||||
|
@ -21,8 +21,8 @@ use Chill\PersonBundle\Security\Authorization\HouseholdVoter;
|
|||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\Form\FormInterface;
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||||
@ -202,7 +202,7 @@ class HouseholdController extends AbstractController
|
|||||||
$this->denyAccessUnlessGranted(HouseholdVoter::EDIT, $household);
|
$this->denyAccessUnlessGranted(HouseholdVoter::EDIT, $household);
|
||||||
|
|
||||||
if (!$request->query->has('address_id')) {
|
if (!$request->query->has('address_id')) {
|
||||||
throw new BadRequestException('parameter address_id is missing');
|
throw new BadRequestHttpException('parameter address_id is missing');
|
||||||
}
|
}
|
||||||
|
|
||||||
$address_id = $request->query->getInt('address_id');
|
$address_id = $request->query->getInt('address_id');
|
||||||
@ -218,7 +218,7 @@ class HouseholdController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (null === $address) {
|
if (null === $address) {
|
||||||
throw new BadRequestException('The edited address does not belongs to the household');
|
throw new BadRequestHttpException('The edited address does not belongs to the household');
|
||||||
}
|
}
|
||||||
|
|
||||||
$form = $this->createForm(AddressDateType::class, $address, []);
|
$form = $this->createForm(AddressDateType::class, $address, []);
|
||||||
|
@ -20,9 +20,9 @@ use Chill\PersonBundle\Form\HouseholdMemberType;
|
|||||||
use Chill\PersonBundle\Household\MembersEditor;
|
use Chill\PersonBundle\Household\MembersEditor;
|
||||||
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
use Symfony\Component\Serializer\Exception;
|
use Symfony\Component\Serializer\Exception;
|
||||||
@ -105,7 +105,7 @@ class HouseholdMemberController extends ApiController
|
|||||||
$ids = $request->query->get('persons', []);
|
$ids = $request->query->get('persons', []);
|
||||||
|
|
||||||
if (0 === count($ids)) {
|
if (0 === count($ids)) {
|
||||||
throw new BadRequestException('parameters persons in query ' .
|
throw new BadRequestHttpException('parameters persons in query ' .
|
||||||
'is not an array or empty');
|
'is not an array or empty');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|||||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
||||||
use Symfony\Component\Form\FormFactoryInterface;
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
@ -494,7 +493,7 @@ final class SingleTaskController extends AbstractController
|
|||||||
);
|
);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new BadRequestException("format not supported: {$_format}");
|
throw new BadRequestHttpException("format not supported: {$_format}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user