sourceRepository = $entityManager->getRepository(AbstractSource::class); } /** * @param UserInterface $user */ private function setUser(?UserInterface $user): void { if ($user) { $this->user = $user; return; } $this->user = new User(); $this->user->setSource($this->sourceRepository->findOneBySlug(SystemSlugType::GUEST_USER)); } /** * @param EntityManagerInterface $entityManager * @param UserInterface $user */ public function __construct(EntityManagerInterface $entityManager, ?UserInterface $user) { $this->setSourceRepository($entityManager); $this->setUser($user); } /** * {@inheritdoc} * * @see \App\Domain\UserManagement\UserIdentityManagerInterface::getUser() */ public function getUser(): UserInterface { return $this->user; } }