diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php index 850fb8ff5..eafb330d5 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseApiController.php @@ -31,7 +31,6 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\ThirdPartyBundle\Entity\ThirdParty; use DateInterval; use DateTimeImmutable; -use JsonSchema\Exception\ValidationException; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Exception\BadRequestException; @@ -323,23 +322,23 @@ final class AccompanyingCourseApiController extends ApiController /** * @Route("/api/1.0/person/accompanying-course/{id}/confidential.json", name="chill_api_person_accompanying_period_confidential") * @ParamConverter("accompanyingCourse", options={"id": "id"}) + * + * @param mixed $id */ public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, $id, Request $request) { - if ($request->getMethod() == 'POST') { - + if ($request->getMethod() === 'POST') { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL, $accompanyingCourse); - $accompanyingCourse->setConfidential(!$accompanyingCourse->isConfidential()); + $accompanyingCourse->setConfidential(!$accompanyingCourse->isConfidential()); - $errors = $this->validator->validate($accompanyingCourse); + $errors = $this->validator->validate($accompanyingCourse); - if ($errors->count() > 0) { - return $this->json($errors, 422); - } else { - $this->getDoctrine()->getManager()->flush(); - } + if ($errors->count() > 0) { + return $this->json($errors, 422); } + $this->getDoctrine()->getManager()->flush(); + } return $this->json($accompanyingCourse->isConfidential(), Response::HTTP_OK, [], ['groups' => ['read']]); } diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 131ecb74b..02620a534 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -38,7 +38,6 @@ use DateTimeInterface; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use JsonSchema\Exception\ValidationException; use LogicException; use Symfony\Component\Serializer\Annotation\DiscriminatorMap; use Symfony\Component\Serializer\Annotation\Groups; diff --git a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php index c6da43174..91e9faa00 100644 --- a/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/AccompanyingPeriod/AccompanyingPeriodConfidentialTest.php @@ -11,12 +11,8 @@ declare(strict_types=1); namespace Chill\PersonBundle\Tests\AccompanyingPeriod; -use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\User; use Chill\PersonBundle\Entity\AccompanyingPeriod; -use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin; -use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; -use Symfony\Component\Validator\Validator\ValidatorInterface; /** * @internal diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidity.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidity.php index e7e51d8c8..ee0df2b99 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidity.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidity.php @@ -18,12 +18,12 @@ use Symfony\Component\Validator\Constraint; */ class AccompanyingPeriodValidity extends Constraint { - public $messageSocialIssueCannotBeDeleted = 'The social %name% issue cannot be deleted because it is associated with an activity or an action'; - public $messageReferrerIsCurrentUser = 'Only the referrer can change the confidentiality of a parcours'; public $messageReferrerIsNull = 'A confidential parcours must have a referrer'; + public $messageSocialIssueCannotBeDeleted = 'The social %name% issue cannot be deleted because it is associated with an activity or an action'; + public function getTargets() { return self::CLASS_CONSTRAINT; diff --git a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php index c29567a43..62e0320e5 100644 --- a/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php +++ b/src/Bundle/ChillPersonBundle/Validator/Constraints/AccompanyingPeriod/AccompanyingPeriodValidityValidator.php @@ -97,14 +97,14 @@ class AccompanyingPeriodValidityValidator extends ConstraintValidator $user = $period->getUser(); $currentUser = $this->token->getToken()->getUser(); - if ($user && ($user != $currentUser) && $period->isConfidential() == true) { + if ($user && ($user !== $currentUser) && $period->isConfidential() === true) { $this->context->buildViolation($constraint->messageReferrerIsCurrentUser) - ->addViolation(); + ->addViolation(); } - if ($user == null && $period->isConfidential() == true) { + if (null === $user && $period->isConfidential() === true) { $this->context->buildViolation($constraint->messageReferrerIsNull) - ->addViolation(); + ->addViolation(); } } }