diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index c7448e07d..94f732a89 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -16,6 +16,7 @@ use InvalidArgumentException; use Symfony\Component\Serializer\Annotation as Serializer; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; +use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * Class ActivityType. @@ -193,7 +194,6 @@ class ActivityType /** * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) - * @Assert\EqualTo(propertyPath="socialIssuesVisible", message="This parameter must be equal to social issue parameter") */ private int $socialActionsVisible = self::FIELD_INVISIBLE; @@ -263,6 +263,23 @@ class ActivityType */ private int $userVisible = self::FIELD_REQUIRED; + /** + * @Assert\Callback + * + * @param mixed $payload + */ + public function checkSocialActionsVisibility(ExecutionContextInterface $context, $payload) + { + if ($this->socialIssuesVisible !== $this->socialActionsVisible) { + if (!($this->socialIssuesVisible === 2 && $this->socialActionsVisible === 1)) { + $context + ->buildViolation('The socialActionsVisible value is not compatible with the socialIssuesVisible value') + ->atPath('socialActionsVisible') + ->addViolation(); + } + } + } + /** * Get active * return true if the type is active. diff --git a/src/Bundle/ChillActivityBundle/translations/validators.fr.yml b/src/Bundle/ChillActivityBundle/translations/validators.fr.yml index 072ac55d2..1f4f97a63 100644 --- a/src/Bundle/ChillActivityBundle/translations/validators.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/validators.fr.yml @@ -20,3 +20,4 @@ For this type of activity, you must add at least one social action: Pour ce type # admin This parameter must be equal to social issue parameter: Ce paramètre doit être égal au paramètre "Visibilité du champs Problématiques sociales" +The socialActionsVisible value is not compatible with the socialIssuesVisible value: Cette valeur du paramètre "Visibilité du champs Actions sociales" n'est pas compatible avec la valeur du paramètre "Visibilité du champs Problématiques sociales" \ No newline at end of file