Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

30 rindas
779B

  1. <?php
  2. namespace Lc\SovBundle\Builder\User;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
  5. use Lc\SovBundle\Model\User\UserInterface;
  6. class UserBuilder
  7. {
  8. protected EntityManagerInterface $entityManager;
  9. public function __construct(EntityManagerInterface $entityManager)
  10. {
  11. $this->entityManager = $entityManager;
  12. }
  13. public function setNewsletter(UserInterface $user, NewsletterInterface $newsletter, bool $subscribeNewsletter): void
  14. {
  15. if ($subscribeNewsletter) {
  16. $user->addNewsletter($newsletter);
  17. } else {
  18. $user->removeNewsletter($newsletter);
  19. }
  20. $this->entityManager->persist($user);
  21. $this->entityManager->flush();
  22. }
  23. }