diff --git a/sources/AppBundle/MembershipFee/MembershipFeeMailer.php b/sources/AppBundle/MembershipFee/MembershipFeeMailer.php index 553f7d7af..d7edb3285 100644 --- a/sources/AppBundle/MembershipFee/MembershipFeeMailer.php +++ b/sources/AppBundle/MembershipFee/MembershipFeeMailer.php @@ -14,6 +14,7 @@ use AppBundle\Email\Mailer\MailUserFactory; use AppBundle\Email\Mailer\Message; use AppBundle\MembershipFee\Model\Repository\MembershipFeeRepository; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Webmozart\Assert\Assert; final readonly class MembershipFeeMailer @@ -24,12 +25,13 @@ public function __construct( private CompanyMemberRepository $companyMemberRepository, private Mailer $mailer, private MembershipFeeInvoicePdfGenerator $pdfGenerator, + #[Autowire('%kernel.project_dir%/../htdocs/cache/')] + private string $publicCacheDir, ) {} /** * Envoi par mail d'une facture au format PDF * - * @param $idCotisation Identifiant de la cotisation * @return bool Succès de l'envoi */ public function envoyerFacture(int $idCotisation): bool @@ -63,7 +65,7 @@ public function envoyerFacture(int $idCotisation): bool $corps .= Afup::ADRESSE . "
"; $corps .= Afup::CODE_POSTAL . " " . Afup::VILLE . "
"; - $cheminFacture = AFUP_CHEMIN_RACINE . 'cache/fact' . $idCotisation . '.pdf'; + $cheminFacture = $this->publicCacheDir . 'fact' . $idCotisation . '.pdf'; $numeroFacture = $this->pdfGenerator->genererFacture($idCotisation, $cheminFacture); $pattern = str_replace(' ', '', $patternPrefix) . '_' . $numeroFacture . '_' . date('dmY', $membership->getStartDate()->getTimestamp()) . '.pdf';