FluidEmail extends Email

Send out templated HTML/plain text emails with Fluid.

Tags
todo:

This construct needs an overhaul because it violates "Composition over inheritance". This is obvious when looking at __construct() already. FluidEmail extends symfony Email (which is a symfony Message), and thus has to deal with things it shouldn't at this point. The repeated calls to $this->resetBody() are the proof something is really wrong here. At first glance it looks as if something like this should happen: The class responsibility should be rendering of the subject and body only. It should probably be created using a factory, returning an instance of some interface, with the factory interface being injected to consumers. This would allow rendering emails with some different template engine, by injecting a different factory interface implementation that returns some different class. With subject and body being created by this, a symfony email should be created (maybe with a facade or factory again). And then hand the mail over to something that can send it. Working on this may go along with a renaming of the class structure, and we may want to ensure abstraction does not explode too much along the way ...

Table of Contents

Constants

FORMAT_BOTH  = 'both'
FORMAT_HTML  = 'html'
FORMAT_PLAIN  = 'plain'

Properties

$format  : array<string|int, string>
$templateName  : string
$view  : FluidViewAdapter

Methods

__construct()  : mixed
assign()  : static
assignMultiple()  : static
ensureValidity()  : void
format()  : static
getBody()  : AbstractPart
getHtmlBody()  : resource|string|null
getTextBody()  : resource|string|null
getViewHelperVariableContainer()  : ViewHelperVariableContainer
setRequest()  : static
setTemplate()  : static
generateTemplatedBody()  : void
getDefaultVariables()  : array<string|int, mixed>
renderContent()  : string
resetBody()  : void

Constants

FORMAT_BOTH

public mixed FORMAT_BOTH = 'both'

FORMAT_HTML

public mixed FORMAT_HTML = 'html'

FORMAT_PLAIN

public mixed FORMAT_PLAIN = 'plain'

Properties

$format

protected array<string|int, string> $format = ['html', 'plain']

$templateName

protected string $templateName = 'Default'

Methods

__construct()

public __construct([TemplatePaths|null $templatePaths = null ][, Headers|null $headers = null ][, AbstractPart|null $body = null ]) : mixed
Parameters
$templatePaths : TemplatePaths|null = null
$headers : Headers|null = null
$body : AbstractPart|null = null

assign()

public assign(mixed $key, mixed $value) : static
Parameters
$key : mixed
$value : mixed
Return values
static

assignMultiple()

public assignMultiple(array<string|int, mixed> $values) : static
Parameters
$values : array<string|int, mixed>
Return values
static

ensureValidity()

public ensureValidity() : void

format()

public format(string $format) : static
Parameters
$format : string
Return values
static

getBody()

public getBody() : AbstractPart
Return values
AbstractPart

getHtmlBody()

public getHtmlBody([bool $forceBodyGeneration = false ]) : resource|string|null
Parameters
$forceBodyGeneration : bool = false
Return values
resource|string|null

getTextBody()

public getTextBody([bool $forceBodyGeneration = false ]) : resource|string|null
Parameters
$forceBodyGeneration : bool = false
Return values
resource|string|null

getViewHelperVariableContainer()

public getViewHelperVariableContainer() : ViewHelperVariableContainer
Internal

Only used for ext:form, not part of TYPO3 Core API.

Return values
ViewHelperVariableContainer

setRequest()

public setRequest(ServerRequestInterface $request) : static
Parameters
$request : ServerRequestInterface
Return values
static

setTemplate()

public setTemplate(string $templateName) : static
Parameters
$templateName : string
Return values
static

generateTemplatedBody()

protected generateTemplatedBody([string $forceFormat = '' ]) : void
Parameters
$forceFormat : string = ''

getDefaultVariables()

protected getDefaultVariables() : array<string|int, mixed>
Return values
array<string|int, mixed>

renderContent()

protected renderContent(string $format) : string
Parameters
$format : string
Return values
string

        
On this page

Search results