Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

44 lines
1.1KB

  1. <?php
  2. namespace domain\Payment;
  3. use domain\User\User\User;
  4. use domain\User\User\UserRepository;
  5. use domain\_\AbstractNotifier;
  6. class PaymentNotifier extends AbstractNotifier
  7. {
  8. protected UserRepository $userRepository;
  9. public function loadDependencies(): void
  10. {
  11. parent::loadDependencies();
  12. $this->userRepository = $this->loadService(UserRepository::class);
  13. }
  14. public function notifyUserCreditMovement(User $user, string $type, float $amount)
  15. {
  16. if($user->email) {
  17. $producer = $this->getProducerContext();
  18. $credit = $this->userRepository->getCredit($user, true);
  19. $this->mailer->sendFromProducer(
  20. 'Mouvement de cagnotte',
  21. 'creditUser',
  22. [
  23. 'user' => $user,
  24. 'producer' => $producer,
  25. 'credit' => $credit,
  26. 'type' => $type,
  27. 'amount' => $amount
  28. ],
  29. $user->email,
  30. $producer
  31. );
  32. return true;
  33. }
  34. return false;
  35. }
  36. }