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 crédit', 'creditUser', [ 'user' => $user, 'producer' => $producer, 'credit' => $credit, 'type' => $type, 'amount' => $amount ], $user->email, $producer ); return true; } return false; } }