Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
34 changes: 30 additions & 4 deletions sources/AppBundle/Event/Sponsorship/SponsorshipLeadMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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();
}
}
4 changes: 2 additions & 2 deletions tests/behat/features/PublicSite/Sponsor.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Feature: Site Public - Devenir sponsor
And I should only receive the following emails:
| to | subject |
| <sponsors@afup.org> | forum - Nouvelle demande de dossier de sponsoring |
| <email@domain.com> | Dossier de sponsoring forum |
| <email@domain.com> | Dossier de sponsoring AFUP |

@reloadDbWithTestData
@clearEmails
Expand All @@ -48,4 +48,4 @@ Feature: Site Public - Devenir sponsor
And I should only receive the following emails:
| to | subject |
| <sponsors@afup.org> | forum - Nouvelle demande de dossier de sponsoring |
| <email@domain.com> | Dossier de sponsoring forum |
| <email@domain.com> | Dossier de sponsoring AFUP |
16 changes: 14 additions & 2 deletions translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,<br />
<p>You have requested to receive the sponsorship file for the %eventName%.</p>

<p>You will find the file as an attachment. For any queries or specifications, do not hesitate to contact us by email at
<a href="mailto:sponsors@afup.org">sponsors@afup.org</a>.</p>
<p>Best regads,<br />
<p>Best regards,<br />
The sponsoring team AFUP</p>

<p>Follow the AFUP on <a href="https://www.linkedin.com/company/afup/">LinkedIn</a>.</p>
<p><a href="https://afup.org">afup.org</a>
'mail.sponsoringfile.text.generic': |
Hello,<br />
<p>You have requested to receive our sponsorship file.</p>

<p>You will find the file as an attachment. For any queries or specifications, do not hesitate to contact us by email at
<a href="mailto:sponsors@afup.org">sponsors@afup.org</a>.</p>
<p>Best regards,<br />
The sponsoring team AFUP</p>

<p>Follow the AFUP on <a href="https://www.linkedin.com/company/afup/">LinkedIn</a>.</p>
Expand Down
12 changes: 12 additions & 0 deletions translations/messages.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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,<br />
<p>Vous avez demandé à recevoir le dossier de sponsoring pour le %eventName%.</p>
Expand All @@ -192,6 +193,17 @@ type.3: "20 mn"
<p>À bientôt,<br />
L’équipe sponsoring AFUP</p>

<p>Suivez l’AFUP sur <a href="https://www.linkedin.com/company/afup/">LinkedIn</a>.</p>
<p><a href="https://afup.org">afup.org</a>
'mail.sponsoringfile.text.generic': |
Bonjour,<br />
<p>Vous avez demandé à recevoir notre dossier de sponsoring.</p>

<p>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 <a href="mailto:sponsors@afup.org">sponsors@afup.org</a>.</p>
<p>À bientôt,<br />
L’équipe sponsoring AFUP</p>

<p>Suivez l’AFUP sur <a href="https://www.linkedin.com/company/afup/">LinkedIn</a>.</p>
<p><a href="https://afup.org">afup.org</a>
Billetterie: Billetterie
Expand Down
Loading