This commit is contained in:
Julie Lenaerts 2021-12-02 15:31:38 +01:00
parent c527b1b3cf
commit 5e7445a4fe
2 changed files with 16 additions and 17 deletions

View File

@ -459,6 +459,20 @@ class AccompanyingPeriod implements
return end($periods) === $this; 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. * Close a participation for a person.
* *
@ -871,21 +885,6 @@ 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 public function isEmergency(): bool
{ {
return $this->emergency; return $this->emergency;

View File

@ -9,10 +9,10 @@
namespace Chill\PersonBundle\Tests\AccompanyingPeriod; namespace Chill\PersonBundle\Tests\AccompanyingPeriod;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\Scope; use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin; use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriod\Origin;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterface;