mirror of
https://github.com/projectsend/projectsend.git
synced 2026-09-17 09:05:08 +00:00
6e47d76ba6
Client file sharing, rebuilt from the ground up: a private area per client, resumable uploads, folders, groups and categories, sharing with expiry dates and download limits, comments, file versions, an activity log, a REST API, and sixteen languages. This repository begins here. ProjectSend 2 was developed privately, and that development history is not published — the previous generation remains available, with its own history, at projectsend/legacy. Free software under the GNU General Public License v2, or (at your option) any later version.
45 lines
1.4 KiB
PHP
45 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Platform\Notifications\Concerns;
|
|
|
|
use App\Modules\Platform\Notifications\EmailTemplateResolver;
|
|
use App\Modules\Platform\Notifications\EmailTemplateSlot;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
/**
|
|
* Shared by every templated Notification class. An override is raw,
|
|
* global text (not translated, not per-locale, matching v1) — the
|
|
* default, non-customized path is untouched and keeps calling __() as
|
|
* before. The action button (if any) is always appended by the caller
|
|
* after this returns; it's never part of the customizable body.
|
|
*/
|
|
trait RendersOverridableMail
|
|
{
|
|
/**
|
|
* @return array{subject: string, body: string}|null
|
|
*/
|
|
protected function overrideOrNull(EmailTemplateSlot $slot): ?array
|
|
{
|
|
return app(EmailTemplateResolver::class)->resolve($slot);
|
|
}
|
|
|
|
/**
|
|
* @param array{subject: string, body: string} $override
|
|
* @param array<string, string> $replacements
|
|
*/
|
|
protected function mailFromOverride(array $override, array $replacements): MailMessage
|
|
{
|
|
$message = (new MailMessage)->subject(strtr($override['subject'], $replacements));
|
|
|
|
foreach (explode("\n\n", trim($override['body'])) as $paragraph) {
|
|
if ($paragraph !== '') {
|
|
$message->line(strtr($paragraph, $replacements));
|
|
}
|
|
}
|
|
|
|
return $message;
|
|
}
|
|
}
|