automaticEmailBuilder = $this->loadService(AutomaticEmailBuilder::class); $this->emailGenerator = $this->loadService(EmailGenerator::class); } public function createAutomaticEmail( Producer $producer, int $day, int $delayBeforeDistribution, string $subject, string $message, bool $integrateProductList = null ): AutomaticEmail { $automaticEmail = $this->automaticEmailBuilder->instanciateAutomaticEmail($producer); $automaticEmail->setDay($day); $automaticEmail->setDelayBeforeDistribution($delayBeforeDistribution); $automaticEmail->setSubject($subject); $automaticEmail->setMessage($message); $automaticEmail->setIntegrateProductList($integrateProductList); $automaticEmail->save(); return $automaticEmail; } public function createEmailFromAutomaticEmail(AutomaticEmail $automaticEmail, Distribution $distribution): Email { return $this->emailGenerator->createEmail( $automaticEmail->getSubject(), $automaticEmail->getMessage(), $automaticEmail->getIntegrateProductList(), $automaticEmail->getProducer(), $distribution ); } }