|
- <?php
-
- namespace domain\Payment;
-
- use domain\User\User\User;
- use domain\User\User\UserRepository;
- use domain\_\AbstractNotifier;
-
- class PaymentNotifier extends AbstractNotifier
- {
- protected UserRepository $userRepository;
-
- public function loadDependencies(): void
- {
- parent::loadDependencies();
- $this->userRepository = $this->loadService(UserRepository::class);
- }
-
- public function notifyUserCreditMovement(User $user, string $type, float $amount)
- {
- if($user->email) {
- $producer = $this->getProducerContext();
- $credit = $this->userRepository->getCredit($user, true);
-
- $this->mailer->sendFromProducer(
- 'Mouvement de cagnotte',
- 'creditUser',
- [
- 'user' => $user,
- 'producer' => $producer,
- 'credit' => $credit,
- 'type' => $type,
- 'amount' => $amount
- ],
- $user->email,
- $producer
- );
-
- return true;
- }
-
- return false;
- }
- }
|