This commit is contained in:
2022-02-17 09:43:49 +01:00
parent c8922a6a82
commit 9861e3fe1c
5 changed files with 15 additions and 21 deletions

View File

@@ -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;

View File

@@ -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();
}
}
}