entityManager = $entityManager; $this->userStore = $userStore; $this->userSolver = $userSolver; } public function setNewsletter(UserInterface $user, NewsletterInterface $newsletter, bool $subscribeNewsletter): void { if ($subscribeNewsletter) { $user->addNewsletter($newsletter); } else { $user->removeNewsletter($newsletter); } $this->entityManager->persist($user); $this->entityManager->flush(); } public function initBlameableSystem(EntityInterface $entity) { $userSystem = $this->userStore->getOneByDevAlias('system'); $this->initBlameable($entity, $userSystem); return $entity; } public function initBlameableUpdatedSystem(EntityInterface $entity) { $userSystem = $this->userStore->getOneByDevAlias('system'); $this->initBlameableUpdated($entity, $userSystem); return $entity; } public function initBlameable(EntityInterface $entity, UserInterface $user) { if ($entity instanceof BlameableInterface) { $entity->setCreatedBy($user); } $this->initBlameableUpdated($entity, $user); } public function initBlameableUpdated(EntityInterface $entity, UserInterface $user) { if ($entity instanceof BlameableInterface) { $entity->setUpdatedBy($user); } } }