This commit is contained in:
2022-02-14 18:00:09 +01:00
parent df61fbff12
commit 8ee451c6e0
8 changed files with 56 additions and 59 deletions

View File

@@ -38,6 +38,7 @@ 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;
@@ -59,11 +60,6 @@ use const SORT_REGULAR;
* "accompanying_period": AccompanyingPeriod::class
* })
* @Assert\GroupSequenceProvider
* @Assert\Expression(
* "this.isConfidential and this.getUser === NULL",
* message="If the accompanying course is confirmed and confidential, a referrer must remain assigned."
* )
*
* @AccompanyingPeriodValidity(groups={AccompanyingPeriod::STEP_DRAFT, AccompanyingPeriod::STEP_CONFIRMED})
*/
class AccompanyingPeriod implements
@@ -340,6 +336,9 @@ class AccompanyingPeriod implements
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=true)
* @Groups({"read", "write", "docgen:read"})
* @Assert\Expression("!this.isConfidential() or (this.isConfidential() and value != null)",
* groups={AccompanyingPeriod::STEP_CONFIRMED},
* message="Referrer cannot be null for a confidential parcours")
*/
private ?User $user = null;
@@ -500,20 +499,6 @@ class AccompanyingPeriod implements
return end($periods) === $this;
}
/**
* @Assert\Callback
*/
public function canUserBeNull(ExecutionContextInterface $context)
{
if ($this->getStep() === self::STEP_CONFIRMED && $this->isConfidential() === true) {
if (!$this->getUser()) {
$context->buildViolation('User cannot be null for an accompanying period that is confirmed and confidential')
->atPath('user')
->addViolation();
}
}
}
/**
* Close a participation for a person.
*