src/Service/AdoptionPollService.php line 168

  1. <?php
  2. namespace App\Service;
  3. use Exception;
  4. use App\Entity\Animal;
  5. use App\Entity\AnimalPoll;
  6. use App\Entity\AnimalPollStatus;
  7. use App\Entity\Species;
  8. use App\Entity\User;
  9. use App\Entity\UserLoyaltyPoint;
  10. use App\Entity\UserLoyaltyPointBid;
  11. use App\Form\AnimalPoll\Step1Form;
  12. use App\Form\AnimalPoll\Step2Form;
  13. use App\Form\AnimalPoll\Step3Form;
  14. use App\Form\AnimalPoll\Step4Form;
  15. use App\Form\AnimalPoll\Step5Form;
  16. use App\Form\AnimalPoll\Step6Form;
  17. use App\Form\AnimalPoll\Step7Form;
  18. use App\Form\AnimalPoll\Step8Form;
  19. use App\Form\AnimalPoll\Step9Form;
  20. use App\Form\AnimalPoll\Step10Form;
  21. use App\Form\AnimalPoll\Step11Form;
  22. use App\Form\AnimalPoll\Step12Form;
  23. use App\Form\AnimalPoll\Step13Form;
  24. use App\Form\AnimalPoll\Step14Form;
  25. use App\Form\AnimalPoll\Step15Form;
  26. use App\Form\AnimalPoll\Step16Form;
  27. use App\Repository\AnimalPollRepository;
  28. use App\Repository\AnimalPollStatusRepository;
  29. use App\Repository\AnimalRepository;
  30. use App\Repository\UserLoyaltyPointBidRepository;
  31. use Doctrine\ORM\QueryBuilder;
  32. use Doctrine\Persistence\ManagerRegistry;
  33. use Symfony\Bridge\Twig\Mime\TemplatedEmail;
  34. use Symfony\Bundle\FrameworkBundle\Routing\Router;
  35. use Symfony\Component\Form\Form;
  36. use Symfony\Component\Form\FormFactory;
  37. use Symfony\Component\Form\FormFactoryInterface;
  38. use Symfony\Component\HttpFoundation\Request;
  39. use Symfony\Component\HttpFoundation\RequestStack;
  40. use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
  41. use Symfony\Component\Mailer\Mailer;
  42. use Symfony\Component\Mailer\MailerInterface;
  43. use Symfony\Component\Mime\Address;
  44. use Symfony\Component\Mime\Email;
  45. use Symfony\Component\Mime\Part\DataPart;
  46. use Symfony\Component\Mime\RawMessage;
  47. use Symfony\Component\Routing\RouterInterface;
  48. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
  49. use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
  50. use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
  51. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  52. use Symfony\Component\Security\Core\Security;
  53. use Twig\Environment;
  54. /**
  55.  * Bag of useful adoption poll methods
  56.  *
  57.  * @author Michał Zbieranek <michal.zbieranek@kansi.pl>
  58.  */
  59. class AdoptionPollService
  60. {
  61.     /** @var ManagerRegistry */
  62.     private $entityManager;
  63.     /** @var Router */
  64.     private $router;
  65.     /** @var TokenStorage */
  66.     private $tokenStorage;
  67.     /** @var FormFactory */
  68.     private $formFactory;
  69.     /** @var RequestStack */
  70.     private $requestStack;
  71.     /** @var AnimalRepository */
  72.     private $animalRepository;
  73.     /** @var AnimalPollRepository */
  74.     private $animalPollRepository;
  75.     /** @var AuthorizationCheckerInterface */
  76.     private $authorizationChecker;
  77.     /** @var AnimalPollStatusRepository */
  78.     private $animalPollStatusRepository;
  79.     /** @var UserLoyaltyPointBidRepository */
  80.     private $userLoyaltyPointBidRepository;
  81.     private Security $security;
  82.     private $forms = [
  83.         Step1Form::class,
  84.         Step2Form::class,
  85.         Step3Form::class,
  86.         Step4Form::class,
  87.         Step5Form::class,
  88.         Step6Form::class,
  89.         Step7Form::class,
  90.         Step8Form::class,
  91.         Step9Form::class,
  92.         Step10Form::class,
  93.         Step11Form::class,
  94.         Step12Form::class,
  95.         Step13Form::class,
  96.         Step14Form::class,
  97.         Step15Form::class,
  98.         Step16Form::class,
  99.     ];
  100.     /**
  101.      * @var Environment
  102.      */
  103.     private Environment $templating;
  104.     /**
  105.      * @var MailerInterface
  106.      */
  107.     private MailerInterface $mailer;
  108.     public function __construct(
  109.         ManagerRegistry $entityManager,
  110.         RouterInterface $router,
  111.         TokenStorageInterface $tokenStorage,
  112.         FormFactoryInterface $formFactory,
  113.         RequestStack $requestStack,
  114.         AnimalRepository $animalRepository,
  115.         AnimalPollRepository $animalPollRepository,
  116.         AnimalPollStatusRepository $animalPollStatusRepository,
  117.         UserLoyaltyPointBidRepository $userLoyaltyPointBidRepository,
  118.         AuthorizationCheckerInterface $authorizationChecker,
  119.         Security $security,
  120.         Environment $templating,
  121.         MailerInterface $mailer
  122.     ) {
  123.         $this->entityManager $entityManager;
  124.         $this->router $router;
  125.         $this->tokenStorage $tokenStorage;
  126.         $this->formFactory $formFactory;
  127.         $this->requestStack $requestStack;
  128.         $this->animalRepository $animalRepository;
  129.         $this->animalPollRepository $animalPollRepository;
  130.         $this->authorizationChecker $authorizationChecker;
  131.         $this->animalPollStatusRepository $animalPollStatusRepository;
  132.         $this->userLoyaltyPointBidRepository $userLoyaltyPointBidRepository;
  133.         $this->security $security;
  134.         $this->templating $templating;
  135.         $this->mailer $mailer;
  136.     }
  137.     /**
  138.      * Return existing AnimalPoll entity or just created new one
  139.      *
  140.      * @param int $animalId
  141.      * @return AnimalPoll
  142.      */
  143.     public function preparePollEntity($animalId$animalPollToken null)
  144.     {
  145.         $animalPoll null;
  146.         $user $this->tokenStorage->getToken()->getUser();
  147.         if (!$user instanceof User) {
  148.             $user null;
  149.         }
  150.         if (empty($animalPollToken)) {
  151.             if ($user) {
  152.                 $existingPoll $this->findAnimalPollFromUser($user$animalId);
  153.             } else {
  154.                 $existingPoll null;
  155.             }
  156.         } else {
  157.             $existingPoll $this->animalPollRepository->findOneBy(['token' => $animalPollToken]);
  158.         }
  159.         if ($existingPoll) {
  160.             $animalPoll $existingPoll;
  161.         } else {
  162.             if ($user) {
  163.                 $existingPoll $this->findAnimalPollFromUser($user);
  164.             } else {
  165.                 $existingPoll null;
  166.             }
  167.             if ($existingPoll) {
  168.                 $newPoll $existingPoll;
  169.                 $newPoll->setCurrentStep(0);
  170.                 $newPoll->setMessage('');
  171.                 $newPoll->setIsMessageSend(false);
  172.                 //Token has to be unique so we don't want to copy it - make new one
  173.                 $newPoll->setToken(md5(uniqid(""true)));
  174.             } else {
  175.                 $newPoll = new AnimalPoll();
  176.                 if ($user) {
  177.                     $newPoll->setCreatedBy($user);
  178.                 }
  179.             }
  180.             $newPoll->setAnimal($this->animalRepository->find($animalId));
  181.             $newPoll->setStatus(
  182.                 $this->animalPollStatusRepository->findOneBy(['type' => AnimalPollStatus::TYPE_INPROGRESS])
  183.             );
  184.             if ($user) {
  185.                 $user->addAnimalPoll($newPoll);
  186.             }
  187.             $animalPoll $newPoll;
  188.         }
  189.         if (!$this->entityManager->getManager()->contains($animalPoll)) {
  190.             $this->entityManager->getManager()->persist($animalPoll);
  191.         }
  192.         $this->entityManager->getManager()->flush();
  193.         return $animalPoll;
  194.     }
  195.     /**
  196.      *
  197.      * @param User $user
  198.      * @param int $animalId = null
  199.      * @return AnimalPoll|null
  200.      */
  201.     private function findAnimalPollFromUser(User $user$animalId null)
  202.     {
  203.         $existingPoll $user->getAnimalPolls()->filter(
  204.             function ($entry) use ($animalId) {
  205.                 if ($animalId) {
  206.                     if ($entry->getAnimal()->getId() == $animalId) {
  207.                         return $entry;
  208.                     } else {
  209.                         return null;
  210.                     }
  211.                 } else {
  212.                     return $entry;
  213.                 }
  214.             }
  215.         )->first();
  216.         if ($existingPoll) {
  217.             return $existingPoll;
  218.         } else {
  219.             return null;
  220.         }
  221.     }
  222.     /**
  223.      * @param AnimalPoll $animalPoll
  224.      */
  225.     private function saveOrAddPollEntity(AnimalPoll $animalPoll)
  226.     {
  227.         $animalPoll->setCurrentStep($this->requestStack->getCurrentRequest()->get('step'0));
  228.         if (!$this->entityManager->getManager()->contains($animalPoll)) {
  229.             $this->entityManager->getManager()->persist($animalPoll);
  230.         }
  231.         $this->entityManager->getManager()->flush();
  232.     }
  233.     /**
  234.      * Current form
  235.      * @param int $step
  236.      * @param int $id
  237.      * @param AnimalPoll $animalPoll
  238.      */
  239.     private function prepareCurrentForm($step$idAnimalPoll $animalPoll)
  240.     {
  241.         $request $this->requestStack->getCurrentRequest();
  242.         //prev-next urls
  243.         if ($step 0) {
  244.             $prevUrl $this->router->generate(
  245.                 $request->get('_route'),
  246.                 ['id' => $id'step' => $step 1'animalPollToken' => $animalPoll->getToken()]
  247.             );
  248.         } else {
  249.             $prevUrl null;
  250.         }
  251.         if ($step count($this->forms) - 1) {
  252.             $nextUrl $this->router->generate(
  253.                 $request->get('_route'),
  254.                 ['id' => $id'step' => $step 1'animalPollToken' => $animalPoll->getToken()]
  255.             );
  256.         } else {
  257.             $nextUrl null;
  258.         }
  259.         $currentForm $this->formFactory->create(
  260.             $this->forms[$step],
  261.             $animalPoll,
  262.             ['nextUrl' => $nextUrl'prevUrl' => $prevUrl]
  263.         );
  264.         return $currentForm;
  265.     }
  266.     /**
  267.      * Prepare form and perform handleRequest
  268.      * @param int $step
  269.      * @param AnimalPoll $animalPoll
  270.      * @return Form
  271.      */
  272.     private function prepareNextForm($stepAnimalPoll $animalPoll)
  273.     {
  274.         if ($step count($this->forms) - 1) {
  275.             $nextForm $this->formFactory->create(
  276.                 $this->forms[$step 1],
  277.                 $animalPoll,
  278.                 ['nextUrl' => ""'prevUrl' => ""]
  279.             );
  280.             $nextForm->handleRequest($this->requestStack->getCurrentRequest());
  281.         } else {
  282.             $nextForm null;
  283.         }
  284.         return $nextForm;
  285.     }
  286.     /**
  287.      * Prepare form and perform handleRequest
  288.      * @param int $step
  289.      * @param AnimalPoll $animalPoll
  290.      * @return Form
  291.      */
  292.     private function preparePrevForm($stepAnimalPoll $animalPoll)
  293.     {
  294.         if ($step 0) {
  295.             $prevForm $this->formFactory->create(
  296.                 $this->forms[$step 1],
  297.                 $animalPoll,
  298.                 ['nextUrl' => ""'prevUrl' => ""]
  299.             );
  300.             $prevForm->handleRequest($this->requestStack->getCurrentRequest());
  301.         } else {
  302.             $prevForm null;
  303.         }
  304.         return $prevForm;
  305.     }
  306.     /**
  307.      * Return final form, depends on context
  308.      * @param AnimalPoll $animalPoll
  309.      * @return Form
  310.      */
  311.     public function prepareForm(AnimalPoll $animalPoll)
  312.     {
  313.         $id $this->requestStack->getCurrentRequest()->get('id');
  314.         $step $this->requestStack->getCurrentRequest()->get('step');
  315.         $prevForm $this->preparePrevForm($step$animalPoll);
  316.         $nextForm $this->prepareNextForm($step$animalPoll);
  317.         $currentForm $this->prepareCurrentForm($step$id$animalPoll);
  318.         //submit prev
  319.         if ($nextForm && $nextForm->isSubmitted()) {
  320.             if ($nextForm->isValid()) {
  321.                 $this->saveOrAddPollEntity($animalPoll);
  322.             } else {
  323.                 $currentForm $nextForm;
  324.             }
  325.         }
  326.         if ($this->requestStack->getCurrentRequest()->get('send') == 1) {
  327.             if (count($this->forms) == $animalPoll->getCurrentStep() + 1) {
  328.                 $status $this->animalPollStatusRepository->findOneBy(['type' => AnimalPollStatus::TYPE_WAITING]);
  329.                 $animalPoll->setStatus($status);
  330.                 $this->finalStepActions($animalPoll);
  331.             }
  332.             $this->saveOrAddPollEntity($animalPoll);
  333.         }
  334.         //submit next
  335.         if ($prevForm && $prevForm->isSubmitted()) {
  336.             if ($prevForm->isValid()) {
  337.                 $this->saveOrAddPollEntity($animalPoll);
  338.                 //handle final step
  339.             } else {
  340.                 $currentForm $prevForm;
  341.             }
  342.         }
  343.         return $currentForm;
  344.     }
  345.     /**
  346.      * @param AnimalPoll $animalPoll
  347.      */
  348.     private function finalStepActions(AnimalPoll $animalPoll)
  349.     {
  350.         $user $this->security->getUser();
  351.         $this->sendThanksEmail($animalPoll$user);
  352.         $this->sendNewAdoptionFormInfoEmail($animalPoll->getAnimal()->getTemporaryHouse(), $animalPoll->getAnimal());
  353.     }
  354.     /**
  355.      * @param AnimalPoll $animalPoll
  356.      * @param User|null $user
  357.      */
  358.     private function sendThanksEmail(AnimalPoll $animalPollUser $user null)
  359.     {
  360.         if ($user) {
  361.             $userEmail $user->getEmail();
  362.             $userName $user->getFirstName();
  363.         } else {
  364.             $userEmail $animalPoll->getEmail();
  365.             $userName $animalPoll->getFirstName();
  366.         }
  367.         $email = (new TemplatedEmail())
  368.             ->from('no-reply@adopciaki.pl')
  369.             ->to(new Address($userEmail))
  370.             ->subject('Podziekowania za wypelnienie ankiety adopcyjnej')
  371.             ->htmlTemplate('front/animal/pollThanksEmail.html.twig')
  372.             ->context([
  373.                 'name' => $userName
  374.             ]);
  375.         try {
  376.             $this->mailer->send($email);
  377.         } catch (TransportExceptionInterface $e) {
  378.             return $e->getMessage();
  379.         }
  380.         return true;
  381.     }
  382.     /**
  383.      * @param User $user
  384.      * @param Animal $animal
  385.      * @return int
  386.      */
  387.     private function sendNewAdoptionFormInfoEmail(User $userAnimal $animal)
  388.     {
  389.         $email = (new TemplatedEmail())
  390.             ->from('no-reply@adopciaki.pl')
  391.             ->bcc('serwis@adopciaki.pl')
  392.             ->to(new Address($user->getEmail()))
  393.             ->subject('Nowa ankieta adopcyjna dla Twojego Adopciaka')
  394.             ->htmlTemplate('front/animal/newAdoptionFormInfoEmail.html.twig')
  395.             ->context([
  396.                 'name' => $user->getFirstName(),
  397.                 'animalName' => $animal->getName()
  398.             ]);
  399.         try {
  400.             $this->mailer->send($email);
  401.         } catch (TransportExceptionInterface $e) {
  402.             return $e->getMessage();
  403.         }
  404.         return true;
  405.     }
  406.     /**
  407.      * @param Request $request
  408.      * @param array $search = []
  409.      * @param array $statusTypes = [string]
  410.      * @param null $isMessageSend
  411.      * @param null $type
  412.      * @return QueryBuilder
  413.      * @throws Exception
  414.      */
  415.     public function prepareIndexQB(
  416.         Request $request,
  417.         array $search,
  418.         $statusTypes = [],
  419.         $isMessageSend null,
  420.         $type null
  421.     ) {
  422.         $order $request->get('o''DESC');
  423.         $sortField $request->get('s''id');
  424.         $animalId $request->get('animalId');
  425.         if ($this->authorizationChecker->isGranted('ROLE_MODERATOR_HOME_TEMPORARY')) {
  426.             $animals null;
  427.         } else {
  428.             $animals $this->security->getUser()->getAnimals();
  429.         }
  430.         $statuses = [];
  431.         if (!empty($statusTypes)) {
  432.             foreach ($statusTypes as $statusType) {
  433.                 $status $this->entityManager->getRepository(AnimalPollStatus::class)->findOneBy(['type' => $statusType]);
  434.                 if (empty($status)) {
  435.                     throw new Exception('Unrecognized status type: '.$statusType);
  436.                 }
  437.                 $statuses[] = $status->getId();
  438.             }
  439.         }
  440.         $animalsQb $this->entityManager->getRepository(AnimalPoll::class)->findAllqb(
  441.             $sortField,
  442.             $order,
  443.             $search,
  444.             $animalId,
  445.             $animals,
  446.             $statuses,
  447.             $isMessageSend,
  448.             $type
  449.         );
  450.         return $animalsQb;
  451.     }
  452.     /**
  453.      * @param AnimalPoll $animalPoll
  454.      * @return int
  455.      */
  456.     public function sendPollResultEmail(AnimalPoll $animalPoll)
  457.     {
  458.         $email = (new TemplatedEmail())
  459.             ->from('no-reply@adopciaki.pl')
  460.             ->to(new Address($animalPoll->getEmail()))
  461.             ->subject('Twoja ankieta adopcyjna została rozpatrzona!')
  462.             ->htmlTemplate('admin/animal_poll/pollResultEmail.html.twig')
  463.             ->context([
  464.                 'animalPoll' => $animalPoll
  465.             ]);
  466.         try {
  467.             $this->mailer->send($email);
  468.         } catch (TransportExceptionInterface $e) {
  469.             return $e->getMessage();
  470.         }
  471.         return true;
  472.     }
  473.     /**
  474.      * @param AnimalPoll $animalPoll
  475.      * @param Form $noteForm
  476.      * @return boolean
  477.      */
  478.     public function handleComment(AnimalPoll $animalPollForm $noteForm)
  479.     {
  480.         $request $this->requestStack->getCurrentRequest();
  481.         $noteForm->handleRequest($request);
  482.         if ($noteForm->isSubmitted() && $noteForm->isValid()) {
  483.             $animalPollNote $noteForm->getData();
  484.             $animalPollNote->setAnimalPoll($animalPoll);
  485.             $animalPoll->addNote($animalPollNote);
  486.             $this->entityManager->getManager()->flush();
  487.             $this->requestStack->getSession()->getFlashBag()->add('info''Komentarz został dodany');
  488.             $this->addCommentLoyaltyPoints($animalPoll);
  489.             return true;
  490.         }
  491.         return false;
  492.     }
  493.     /**
  494.      *
  495.      * @param AnimalPoll $animalPoll
  496.      * @param Form $acceptanceForm
  497.      * @return boolean
  498.      */
  499.     public function handleAcceptance(AnimalPoll $animalPollForm $acceptanceForm)
  500.     {
  501.         $request $this->requestStack->getCurrentRequest();
  502.         $acceptanceForm->handleRequest($request);
  503.         if ($acceptanceForm->isSubmitted()) {
  504.             if ($acceptanceForm->get('accept')->isClicked()) {
  505.                 $animalPoll->setStatus(
  506.                     $this->animalPollStatusRepository->findOneBy(['type' => AnimalPollStatus::TYPE_ACCEPTED])
  507.                 );
  508.                 $this->entityManager->getManager()->flush();
  509.                 $this->requestStack->getSession()->getFlashBag()->add('info''Ankieta została zaakceptowana');
  510.             }
  511.             if ($acceptanceForm->get('reject')->isClicked()) {
  512.                 $animalPoll->setStatus(
  513.                     $this->animalPollStatusRepository->findOneBy(['type' => AnimalPollStatus::TYPE_REJECTED])
  514.                 );
  515.                 $this->entityManager->getManager()->flush();
  516.                 $this->requestStack->getSession()->getFlashBag()->add('info''Ankieta została odrzucona');
  517.             }
  518.             $this->addAceptanceLoyaltyPoints($animalPoll);
  519.             return true;
  520.         }
  521.         return false;
  522.     }
  523.     /**
  524.      *
  525.      * @param AnimalPoll $animalPoll
  526.      * @param Form $messageForm
  527.      * @return boolean
  528.      */
  529.     public function handleMessage(AnimalPoll $animalPollForm $messageForm)
  530.     {
  531.         $request $this->requestStack->getCurrentRequest();
  532.         $messageForm->handleRequest($request);
  533.         if ($messageForm->isSubmitted() && $messageForm->isValid()) {
  534.             if ($messageForm->get('accept')->isClicked()) {
  535.                 //if dont sent message is checked not send message
  536.                 if ($messageForm->get('dontSendMessage')->getViewData() == '1') {
  537.                     $this->requestStack->getSession()->getFlashBag()->add(
  538.                         'info',
  539.                         'Ankieta jest zmoderowana, wiadomość nie została wysłana do użytkownika'
  540.                     );
  541.                     $animalPoll->setDontSendMessage(true);
  542.                     $animalPoll->setIsMessageSend(true);
  543.                     $this->entityManager->getManager()->flush();
  544.                 } else {
  545.                     $animalPoll->setIsMessageSend(true);
  546.                     $this->entityManager->getManager()->flush();
  547.                     $this->sendPollResultEmail($animalPoll);
  548.                     $this->requestStack->getSession()->getFlashBag()->add(
  549.                         'info',
  550.                         'Wiadomość została zaakceptowana i zostanie wysłana do użytkownika'
  551.                     );
  552.                 }
  553.                 return true;
  554.             }
  555.         }
  556.         return false;
  557.     }
  558.     /**
  559.      *
  560.      */
  561.     private function addAceptanceLoyaltyPoints(AnimalPoll $animalPoll)
  562.     {
  563.         $acceptType UserLoyaltyPointBid::TYPE_ADOPTION_ACCEPTANCE;
  564.         if ($animalPoll->getAnimal()->getSpecies()->getType() == Species::TYPE_DOG) {
  565.             $acceptType UserLoyaltyPointBid::TYPE_ADOPTION_ACCEPTANCE_DOG;
  566.         }
  567.         $this->addLoyaltyPoints($acceptType);
  568.     }
  569.     /**
  570.      * Add points for comment (only first by that user)
  571.      */
  572.     private function addCommentLoyaltyPoints(AnimalPoll $animalPoll)
  573.     {
  574.         $pollCommType UserLoyaltyPointBid::TYPE_ADOPTION_POLL_COMMENT;
  575.         if ($animalPoll->getAnimal()->getSpecies()->getType() == Species::TYPE_DOG) {
  576.             $pollCommType UserLoyaltyPointBid::TYPE_ADOPTION_POOL_COMMENT_DOG;
  577.         }
  578.         $userNumberOfNotes $animalPoll->getNotes()->count();
  579.         if ($userNumberOfNotes == 1) {
  580.             $this->addLoyaltyPoints($pollCommType);
  581.         }
  582.     }
  583.     /**
  584.      *
  585.      * @param type $type UserLoyaltyPointBid::TYPE_*
  586.      */
  587.     private function addLoyaltyPoints($type)
  588.     {
  589.         $user $this->tokenStorage->getToken()->getUser();
  590.         if ($user->hasRole('ROLE_HOME_TEMPORARY')) {
  591.             $bid $this->userLoyaltyPointBidRepository->findOneBy(['type' => $type]);
  592.             $loyaltyPoint = new UserLoyaltyPoint();
  593.             $loyaltyPoint->setUser($user);
  594.             $loyaltyPoint->setName($bid->getName());
  595.             $loyaltyPoint->setType($bid->getType());
  596.             $loyaltyPoint->setValue($bid->getValue());
  597.             $user->addLoyaltyPoint($loyaltyPoint);
  598.             $this->entityManager->getManager()->flush();
  599.         }
  600.     }
  601.     /**
  602.      * Ugly! Proxy method, should be refactored
  603.      * @param AnimalPoll $poll
  604.      * @todo final steps should be moved to AnimalPollManager class
  605.      */
  606.     public function finalizeProxy(AnimalPoll $poll): void
  607.     {
  608.         $this->finalStepActions($poll);
  609.     }
  610.     /**
  611.      * Ugly! Proxy method, should be refactored
  612.      * @param AnimalPoll $animalPoll
  613.      * @todo sending emails should be moved to AnimalPollManager class
  614.      */
  615.     public function ProxySendNewAdoptionFormInfoEmail(AnimalPoll $animalPoll)
  616.     {
  617.         $this->sendNewAdoptionFormInfoEmail($animalPoll->getAnimal()->getTemporaryHouse(), $animalPoll->getAnimal());
  618.     }
  619. }