41 lines
1.3 KiB
PHP
41 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Email;
|
|
|
|
use App\Entity\Disposition;
|
|
|
|
/**
|
|
* Builds the placeholder maps that more than one caller needs.
|
|
*
|
|
* The disposition reminder is sent both by the nightly cron and by
|
|
* EmailNotificationSubscriber when a contract is confirmed shortly before departure; both
|
|
* have to fill the same placeholders, and a map that drifts between them would show "-"
|
|
* in one of the two mails.
|
|
*/
|
|
class MailPlaceholderFactory
|
|
{
|
|
public function __construct(
|
|
private readonly int $invoiceUploadDeadlineDays,
|
|
) {
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string|int|null>
|
|
*/
|
|
public function forDispositionReminder(Disposition $disposition, int $diffInDays): array
|
|
{
|
|
$assignment = $disposition->getAssignment();
|
|
$destination = $assignment->getDestination();
|
|
|
|
return [
|
|
'destination' => (string) $destination,
|
|
'jobProfile' => $assignment->getJobProfile()?->getName(),
|
|
'product' => $destination->getProduct(),
|
|
'dateFrom' => $destination->getDateFrom()?->format('d.m.Y'),
|
|
'dateTo' => $destination->getDateTo()?->format('d.m.Y'),
|
|
'diffInDays' => $diffInDays,
|
|
'invoiceUploadDeadlineDays' => $this->invoiceUploadDeadlineDays,
|
|
];
|
|
}
|
|
}
|