mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
validation attempt with assert\callback: still doesn't work
This commit is contained in:
@@ -49,10 +49,6 @@ use UnexpectedValueException;
|
||||
* "accompanying_period": AccompanyingPeriod::class
|
||||
* })
|
||||
* @Assert\GroupSequenceProvider
|
||||
* @Assert\Expression(
|
||||
* "this.isConfidential && this.getUser && this.getStep === 'CONFIRMED'",
|
||||
* message="If the accompanying course is confirmed and confidential, a referrer must remain assigned."
|
||||
* )
|
||||
*/
|
||||
class AccompanyingPeriod implements
|
||||
TrackCreationInterface,
|
||||
@@ -860,7 +856,7 @@ class AccompanyingPeriod implements
|
||||
}
|
||||
|
||||
/**
|
||||
* Validation function.
|
||||
* Validation functions.
|
||||
*/
|
||||
public function isDateConsistent(ExecutionContextInterface $context)
|
||||
{
|
||||
@@ -875,6 +871,21 @@ class AccompanyingPeriod implements
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function isEmergency(): bool
|
||||
{
|
||||
return $this->emergency;
|
||||
|
Reference in New Issue
Block a user