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.
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Platform\Theming;
|
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
/**
|
|
* Renders a MailMessage to HTML through a specific theme, for previewing
|
|
* only — never for an actual send. Shares `mail_theme`/`mail_theme_context`
|
|
* the same way ThemedMailChannel does at real send time, so a premium
|
|
* theme's extra context (e.g. Branded's logo) shows exactly as it would
|
|
* in production. Used both for previewing a theme itself
|
|
* (ThemingSettingsController) and for previewing a specific template's
|
|
* effective content under the currently active theme
|
|
* (EmailTemplatesController).
|
|
*/
|
|
class EmailPreviewRenderer
|
|
{
|
|
public function __construct(
|
|
private readonly EmailThemeRegistry $themes,
|
|
) {}
|
|
|
|
public function render(MailMessage $message, string $themeKey): string
|
|
{
|
|
$context = $this->themes->get($themeKey)?->context;
|
|
|
|
View::share('mail_theme', $themeKey);
|
|
View::share('mail_theme_context', $context === null ? [] : $context());
|
|
|
|
return (string) $message->theme($themeKey)->render();
|
|
}
|
|
}
|