class MailFormatter

The formatter email views are given.

Renders through the real formatter, then puts back the values {\Flarum\Mail\MailTranslator} held out of the way, escaped. Content that never went through the mail translator — a post's body via `formatContent()`, for instance — is unaffected, since it carries no markers. Not a subclass: email views only ever call `convert()`, and wrapping avoids inheriting the parser and renderer state the real formatter manages.

Methods

__construct( Formatter $formatter)

No description

string
convert(string|null $content)

No description

string
htmlToPlain(string|null $content)

Turn a slot of the plain-text layout into text: tags removed, entities decoded. Slots arrive as rendered Blade, so whatever a view printed with `{{ }}` is escaped already, and plain text has nothing to escape.

string
plainToHtml(string|null $content)

Turn plain text an email view was handed into HTML: escaped, with its line breaks kept and its URLs made clickable.

mixed
__call(string $method, array $arguments)

Anything else an email view might reach for goes to the real formatter.

Details

__construct( Formatter $formatter)

Parameters

Formatter $formatter

string convert(string|null $content)

Parameters

string|null $content

Return Value

string

string htmlToPlain(string|null $content)

Turn a slot of the plain-text layout into text: tags removed, entities decoded. Slots arrive as rendered Blade, so whatever a view printed with `{{ }}` is escaped already, and plain text has nothing to escape.

Parameters

string|null $content

Return Value

string

string plainToHtml(string|null $content)

Turn plain text an email view was handed into HTML: escaped, with its line breaks kept and its URLs made clickable.

Informational emails (account activation, email confirmation, password reset) do not build their body in a view. It arrives already translated, so its parameters, a display name among them, are part of the string by the time a template sees it, and no markers are left for {\Flarum\Mail\SafeSubstitution} to put back. Rendering such a body with `convert()` would therefore put those values in front of the parser, which is the thing the mail translator exists to prevent. The content is escaped instead, and only URLs are linked: the visible text of every link produced here is the address it points at.

Parameters

string|null $content

Return Value

string

mixed __call(string $method, array $arguments)

Anything else an email view might reach for goes to the real formatter.

Parameters

string $method
array $arguments

Return Value

mixed