diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 8d46fc323..99aa394f1 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -7603,12 +7603,6 @@ 'count' => 1, 'path' => __DIR__ . '/sources/AppBundle/Event/Sponsorship/SponsorshipLeadMail.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getTitle\\(\\) on AppBundle\\\\Event\\\\Model\\\\Event\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 2, - 'path' => __DIR__ . '/sources/AppBundle/Event/Sponsorship/SponsorshipLeadMail.php', -]; $ignoreErrors[] = [ 'message' => '#^Cannot access offset \'\\.aggregation\' on mixed\\.$#', 'identifier' => 'offsetAccess.nonOffsetAccessible', diff --git a/sources/AppBundle/Event/Sponsorship/SponsorshipLeadMail.php b/sources/AppBundle/Event/Sponsorship/SponsorshipLeadMail.php index 282d510aa..156242488 100644 --- a/sources/AppBundle/Event/Sponsorship/SponsorshipLeadMail.php +++ b/sources/AppBundle/Event/Sponsorship/SponsorshipLeadMail.php @@ -11,6 +11,7 @@ use AppBundle\Email\Mailer\Message; use AppBundle\Event\Model\Event; use AppBundle\Event\Model\Lead; +use AppBundle\Event\Model\Repository\EventRepository; use Psr\Log\LoggerInterface; use Symfony\Contracts\Translation\TranslatorInterface; @@ -20,25 +21,50 @@ public function __construct( private readonly Mailer $mailer, private readonly TranslatorInterface $translator, private readonly LoggerInterface $logger, + private readonly EventRepository $eventRepository, ) {} public function sendSponsorshipFile(Lead $lead): void { $file = Event::getSponsorFilePath($lead->getEvent()->getPath(), $lead->getLanguage()); - $subject = $this->translator->trans('mail.sponsoringfile.title', ['%eventName%' => $lead->getEvent()->getTitle()]); + $event = $this->getSingleUpcomingEvent(); + + if ($event === null) { + $subject = $this->translator->trans('mail.sponsoringfile.title.generic'); + $content = $this->translator->trans('mail.sponsoringfile.text.generic'); + $filename = sprintf('dossier-sponsoring-afup-%s.pdf', $lead->getLanguage()); + } else { + $subject = $this->translator->trans('mail.sponsoringfile.title', ['%eventName%' => $event->getTitle()]); + $content = $this->translator->trans('mail.sponsoringfile.text', ['%eventName%' => $event->getTitle()]); + $filename = basename($file); + } + $message = new Message($subject, MailUserFactory::sponsors(), new MailUser($lead->getEmail(), $lead->getLabel())); $message->addAttachment(new Attachment( $file, - basename($file), + $filename, 'base64', 'application/pdf', )); - $content = $this->translator->trans('mail.sponsoringfile.text', ['%eventName%' => $lead->getEvent()->getTitle()]); - if (!$this->mailer->sendTransactional($message, $content)) { $this->logger->warning(sprintf('Mail not sent for sponsorship lead retrieval: "%s"', $lead->getEmail())); } } + + /** + * Le dossier de sponsoring couvre tous les évènements à venir : il n'est + * nommé que lorsqu'un seul évènement est à venir. + */ + private function getSingleUpcomingEvent(): ?Event + { + $events = $this->eventRepository->getNextEvents(); + + if ($events === null || $events->count() !== 1) { + return null; + } + + return $events->first(); + } } diff --git a/tests/behat/features/PublicSite/Sponsor.feature b/tests/behat/features/PublicSite/Sponsor.feature index 6ae601830..7bd99cccd 100644 --- a/tests/behat/features/PublicSite/Sponsor.feature +++ b/tests/behat/features/PublicSite/Sponsor.feature @@ -27,7 +27,7 @@ Feature: Site Public - Devenir sponsor And I should only receive the following emails: | to | subject | | | forum - Nouvelle demande de dossier de sponsoring | - | | Dossier de sponsoring forum | + | | Dossier de sponsoring AFUP | @reloadDbWithTestData @clearEmails @@ -48,4 +48,4 @@ Feature: Site Public - Devenir sponsor And I should only receive the following emails: | to | subject | | | forum - Nouvelle demande de dossier de sponsoring | - | | Dossier de sponsoring forum | + | | Dossier de sponsoring AFUP | diff --git a/translations/messages.en.yml b/translations/messages.en.yml index acc2bf2be..436f01b7a 100644 --- a/translations/messages.en.yml +++ b/translations/messages.en.yml @@ -134,14 +134,26 @@ Billetterie: Ticketing "Que vous ayez une offre à promouvoir, un produit à présenter ou que vous souhaitiez soutenir l'open source,\n nous aurons une offre à vous proposer.": "Whether you have an offer to promote, a product to present or you want to support open source, we will have a sponsorship package to offer you." "Avec ou sans stand lors de l'évènement, nos différents niveaux de sponsoring vous permettent de trouver\n une offre qui correspond à vos attentes de visibilité tout en respectant votre budget.": "With or without a booth during the event, our different levels of sponsorship allow you to find an offer that meets your expectations of visibility while respecting your budget." "Pour les sponsors, cet évènement est l'occasion unique à Paris de rencontrer autant de développeur·se·s\n web dans un cadre convivial.": "For sponsors, this event is the unique opportunity in Paris to meet as many web developers in a friendly setting." -'mail.sponsoringfile.title': 'Sponsoring file %eventName%' +'mail.sponsoringfile.title': '%eventName% sponsoring file' +'mail.sponsoringfile.title.generic': 'AFUP sponsoring file' 'mail.sponsoringfile.text': | Hello,

You have requested to receive the sponsorship file for the %eventName%.

You will find the file as an attachment. For any queries or specifications, do not hesitate to contact us by email at sponsors@afup.org.

-

Best regads,
+

Best regards,
+ The sponsoring team AFUP

+ +

Follow the AFUP on LinkedIn.

+

afup.org +'mail.sponsoringfile.text.generic': | + Hello,
+

You have requested to receive our sponsorship file.

+ +

You will find the file as an attachment. For any queries or specifications, do not hesitate to contact us by email at + sponsors@afup.org.

+

Best regards,
The sponsoring team AFUP

Follow the AFUP on LinkedIn.

diff --git a/translations/messages.fr.yml b/translations/messages.fr.yml index 566e068b1..6721b09d8 100644 --- a/translations/messages.fr.yml +++ b/translations/messages.fr.yml @@ -183,6 +183,7 @@ type.3: "20 mn" 'Language': 'Langue' 'Become a sponsor': 'Devenir sponsor' 'mail.sponsoringfile.title': 'Dossier de sponsoring %eventName%' +'mail.sponsoringfile.title.generic': 'Dossier de sponsoring AFUP' 'mail.sponsoringfile.text': | Bonjour,

Vous avez demandé à recevoir le dossier de sponsoring pour le %eventName%.

@@ -192,6 +193,17 @@ type.3: "20 mn"

À bientôt,
L’équipe sponsoring AFUP

+

Suivez l’AFUP sur LinkedIn.

+

afup.org +'mail.sponsoringfile.text.generic': | + Bonjour,
+

Vous avez demandé à recevoir notre dossier de sponsoring.

+ +

Vous trouverez le dossier en pièce jointe. Pour toute demande de précisions ou devis, + n'hésitez pas à nous contacter par mail à l’adresse sponsors@afup.org.

+

À bientôt,
+ L’équipe sponsoring AFUP

+

Suivez l’AFUP sur LinkedIn.

afup.org Billetterie: Billetterie