mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 19:43:49 +00:00
[activity] handle case when there is no action associated to selected
issues
This commit is contained in:
@@ -10,10 +10,12 @@
|
||||
namespace Chill\ActivityBundle\Validator\Constraints;
|
||||
|
||||
use Chill\ActivityBundle\Entity\Activity;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintValidator;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
|
||||
use Symfony\Component\Validator\Exception\UnexpectedValueException;
|
||||
use function array_merge;
|
||||
|
||||
class ActivityValidityValidator extends ConstraintValidator
|
||||
{
|
||||
@@ -118,9 +120,19 @@ class ActivityValidityValidator extends ConstraintValidator
|
||||
}
|
||||
|
||||
if ($activity->getActivityType()->getSocialActionsVisible() === 2 && $activity->getSocialActions()->count() === 0) {
|
||||
$this->context
|
||||
->buildViolation($constraint->socialActionsMessage)
|
||||
->addViolation();
|
||||
// check if a social action may be added
|
||||
$actions = [];
|
||||
|
||||
foreach ($activity->getSocialIssues() as $socialIssue) {
|
||||
/** @var SocialIssue $socialIssue */
|
||||
$actions = array_merge($actions, $socialIssue->getRecursiveSocialActions()->toArray());
|
||||
}
|
||||
|
||||
if (0 < count($actions)) {
|
||||
$this->context
|
||||
->buildViolation($constraint->socialActionsMessage)
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user