do not add referrer if user is null (fix condition)

This commit is contained in:
Julien Fastré 2022-03-21 15:21:29 +01:00
parent efeda81e05
commit 704392a729

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\EventListener;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod\AccompanyingPeriodWork;
use Symfony\Component\Security\Core\Security;
@ -25,7 +26,7 @@ class AccompanyingPeriodWorkEventListener
public function prePersistAccompanyingPeriodWork(AccompanyingPeriodWork $work): void
{
if (null !== $this->security->getUser()) {
if ($this->security->getUser() instanceof User) {
$work->addReferrer($this->security->getUser());
}
}