mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
csfixes
This commit is contained in:
parent
c8922a6a82
commit
9861e3fe1c
@ -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,11 +322,12 @@ 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());
|
||||
@ -336,9 +336,8 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
|
||||
if ($errors->count() > 0) {
|
||||
return $this->json($errors, 422);
|
||||
} else {
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
}
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
}
|
||||
|
||||
return $this->json($accompanyingCourse->isConfidential(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -97,12 +97,12 @@ 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();
|
||||
}
|
||||
|
||||
if ($user == null && $period->isConfidential() == true) {
|
||||
if (null === $user && $period->isConfidential() === true) {
|
||||
$this->context->buildViolation($constraint->messageReferrerIsNull)
|
||||
->addViolation();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user