PHP Class EmailTemplate, vanilla

Afficher le fichier Open project: vanilla/vanilla Class Usage Examples

Protected Properties

Свойство Type Description
$backgroundColor The hex color code of the background, must include the leading '#'.
$button An array representing a button with the following keys: 'url' => The href value of the button. 'text' => The button text. 'textColor' => The hex color code of the button text, must include the leading '#'. 'backgroundColor' => The hex color code of the button background, must include the leading '#'.
$containerBackgroundColor The hex color code of the container background, must include the leading '#'.
$defaultButtonBackgroundColor The default hex color code of the button background, must include the leading '#'.
$defaultButtonTextColor The default hex color code of the button text, must include the leading '#'.
$footer An array representing a footer with the following keys: 'text' => The HTML-formatted footer text. 'textColor' => The hex color code of the footer text, must include the leading '#'. 'backgroundColor' => The hex color code of the footer background, must include the leading '#'.
$image An array representing an image with the following keys: 'source' => The image source url. 'link' => The href value of the image wrapper. 'alt' => The alt value of the image tag.
$lead The HTML formatted email lead (sub-title, appears under title).
$message The HTML formatted email message (the body of the email).
$plaintext Whether to render in plaintext.
$textColor The hex color code of the text, must include the leading '#'.
$title The HTML formatted email title.
$view The path to the email view.

Méthodes publiques

Méthode Description
__construct ( string $message = '', string $title = '', string $lead = '', string $view = 'email-basic' )
getBackgroundColor ( ) : string
getContainerBackgroundColor ( ) : string
getDefaultButtonBackgroundColor ( ) : string
getDefaultButtonTextColor ( ) : string
getDefaultEmailImage ( ) : array Retrieves default values for the email image.
getFooter ( ) : string
getImage ( ) : array
getLead ( ) : string
getMessage ( ) : string
getTextColor ( ) : string
getTitle ( ) : string
isPlaintext ( ) : boolean
removeButton ( ) : EmailTemplate Remove the button.
setBackgroundColor ( string $color ) : EmailTemplate
setButton ( string $url, string $text, string $textColor = '', string $backgroundColor = '' ) : EmailTemplate Set the button property.
setContainerBackgroundColor ( string $color ) : EmailTemplate
setDefaultButtonBackgroundColor ( string $color ) : EmailTemplate Sets the default color for the button background.
setDefaultButtonTextColor ( string $color ) : EmailTemplate Sets the default color for the button text.
setFooter ( string $text, string $textColor = '', string $backgroundColor = '' ) : EmailTemplate Sets the footer. The footer background and text colors default to the button background and text colors.
setImage ( string $sourceUrl = '', string $linkUrl = '', string $alt = '' ) : EmailTemplate Set the image property.
setImageArray ( $image ) : EmailTemplate Set the image property using an array with the following keys: 'source' => The image source url.
setLead ( string $lead ) : EmailTemplate
setMessage ( string $message, boolean $convertNewlines = false, boolean $filter = false ) : EmailTemplate
setPlaintext ( boolean $plainText )
setTextColor ( string $color ) : EmailTemplate
setTitle ( string $title ) : EmailTemplate
setView ( string $view, string $controllerName = 'email', string $applicationFolder = 'dashboard' ) : EmailTemplate
toString ( ) : string Render the email.

Méthodes protégées

Méthode Description
formatContent ( string $html, boolean $convertNewlines = false, boolean $filter = false ) : string Filters an unsafe HTML string and returns it.
objectToArray ( EmailTemplate $email ) : array Copies the email object to an array. A simple (array) typecast won't work, since the properties are protected and as such, add unwanted information to the array keys.
plainTextEmail ( ) : string Renders a plaintext email.
setDefaultEmailImage ( ) Sets the default image for the email template.

Method Details

__construct() public méthode

public __construct ( string $message = '', string $title = '', string $lead = '', string $view = 'email-basic' )
$message string HTML formatted email message (the body of the email).
$title string HTML formatted email title.
$lead string HTML formatted email lead (sub-title, appears under title).
$view string

formatContent() protected méthode

Filters an unsafe HTML string and returns it.
protected formatContent ( string $html, boolean $convertNewlines = false, boolean $filter = false ) : string
$html string The HTML to filter.
$convertNewlines boolean Whether to convert new lines to html br tags.
$filter boolean Whether to escape HTML or not.
Résultat string The filtered HTML string.

getBackgroundColor() public méthode

public getBackgroundColor ( ) : string
Résultat string The hex color code of the background.

getContainerBackgroundColor() public méthode

public getContainerBackgroundColor ( ) : string
Résultat string The hex color code of the container background.

getDefaultButtonBackgroundColor() public méthode

public getDefaultButtonBackgroundColor ( ) : string
Résultat string The default hex color code of the button background, must include the leading '#'.

getDefaultButtonTextColor() public méthode

public getDefaultButtonTextColor ( ) : string
Résultat string The default hex color code of the button text, must include the leading '#'.

getDefaultEmailImage() public méthode

Retrieves default values for the email image.
public getDefaultEmailImage ( ) : array
Résultat array An array representing an image.

getFooter() public méthode

public getFooter ( ) : string
Résultat string The HTML formatted email footer.

getImage() public méthode

public getImage ( ) : array
Résultat array An array representing an image with the following keys: 'source' => The image source url. 'link' => The href value of the image wrapper. 'alt' => The alt value of the image tag.

getLead() public méthode

public getLead ( ) : string
Résultat string The HTML formatted email lead (sub-title, appears under title).

getMessage() public méthode

public getMessage ( ) : string
Résultat string The HTML formatted email message (the body of the email).

getTextColor() public méthode

public getTextColor ( ) : string
Résultat string The hex color code of the text.

getTitle() public méthode

public getTitle ( ) : string
Résultat string The HTML formatted email title.

isPlaintext() public méthode

public isPlaintext ( ) : boolean
Résultat boolean Whether to render in plaintext.

objectToArray() protected méthode

Copies the email object to an array. A simple (array) typecast won't work, since the properties are protected and as such, add unwanted information to the array keys.
protected objectToArray ( EmailTemplate $email ) : array
$email EmailTemplate The email object.
Résultat array Copy of email object in an array format for output.

plainTextEmail() protected méthode

Renders a plaintext email.
protected plainTextEmail ( ) : string
Résultat string A plaintext email.

removeButton() public méthode

Remove the button.
public removeButton ( ) : EmailTemplate
Résultat EmailTemplate $this The calling object.

setBackgroundColor() public méthode

public setBackgroundColor ( string $color ) : EmailTemplate
$color string The hex color code of the background, must include the leading '#'.
Résultat EmailTemplate $this The calling object.

setButton() public méthode

Set the button property.
public setButton ( string $url, string $text, string $textColor = '', string $backgroundColor = '' ) : EmailTemplate
$url string The href value of the button.
$text string The button text.
$textColor string The hex color code of the button text, must include the leading '#'.
$backgroundColor string The hex color code of the button background, must include the leading '#'.
Résultat EmailTemplate $this The calling object.

setContainerBackgroundColor() public méthode

public setContainerBackgroundColor ( string $color ) : EmailTemplate
$color string The hex color code of the container background, must include the leading '#'.
Résultat EmailTemplate $this The calling object.

setDefaultButtonBackgroundColor() public méthode

The background color of the EmailTemplate's button property can be overridden by setting $button['backgroundColor']
public setDefaultButtonBackgroundColor ( string $color ) : EmailTemplate
$color string The default hex color code of the button background, must include the leading '#'.
Résultat EmailTemplate $this The calling object.

setDefaultButtonTextColor() public méthode

The text color of the EmailTemplate's button property can be overridden by setting $button['textColor']
public setDefaultButtonTextColor ( string $color ) : EmailTemplate
$color string The default hex color code of the button text, must include the leading '#'.
Résultat EmailTemplate $this The calling object.

setDefaultEmailImage() protected méthode

Sets the default image for the email template.
protected setDefaultEmailImage ( )

setFooter() public méthode

Sets the footer. The footer background and text colors default to the button background and text colors.
public setFooter ( string $text, string $textColor = '', string $backgroundColor = '' ) : EmailTemplate
$text string The HTML formatted email footer text.
$textColor string The hex color code of the footer text, must include the leading '#'.
$backgroundColor string The hex color code of the footer background, must include the leading '#'.
Résultat EmailTemplate $this The calling object.

setImage() public méthode

Set the image property.
public setImage ( string $sourceUrl = '', string $linkUrl = '', string $alt = '' ) : EmailTemplate
$sourceUrl string The image source url.
$linkUrl string The href value of the image wrapper.
$alt string The alt value of the img tag.
Résultat EmailTemplate $this The calling object.

setImageArray() public méthode

'link' => The href value of the image wrapper. 'alt' => The alt value of the img tag.
public setImageArray ( $image ) : EmailTemplate
Résultat EmailTemplate $this The calling object.

setLead() public méthode

public setLead ( string $lead ) : EmailTemplate
$lead string The HTML formatted email lead (sub-title, appears under title).
Résultat EmailTemplate $this The calling object.

setMessage() public méthode

public setMessage ( string $message, boolean $convertNewlines = false, boolean $filter = false ) : EmailTemplate
$message string The HTML formatted email message (the body of the email).
$convertNewlines boolean Whether to convert new lines to html br tags.
$filter boolean Whether to filter HTML or not.
Résultat EmailTemplate $this The calling object.

setPlaintext() public méthode

public setPlaintext ( boolean $plainText )
$plainText boolean Whether to render in plaintext.

setTextColor() public méthode

public setTextColor ( string $color ) : EmailTemplate
$color string The hex color code of the text, must include the leading '#'.
Résultat EmailTemplate $this The calling object.

setTitle() public méthode

public setTitle ( string $title ) : EmailTemplate
$title string The HTML formatted email title.
Résultat EmailTemplate $this The calling object.

setView() public méthode

public setView ( string $view, string $controllerName = 'email', string $applicationFolder = 'dashboard' ) : EmailTemplate
$view string The view name.
$controllerName string The controller name for the view.
$applicationFolder string The application folder for the view.
Résultat EmailTemplate $this The calling object.

toString() public méthode

Render the email.
public toString ( ) : string
Résultat string The rendered email.

Property Details

$backgroundColor protected_oe property

The hex color code of the background, must include the leading '#'.
protected $backgroundColor

$button protected_oe property

An array representing a button with the following keys: 'url' => The href value of the button. 'text' => The button text. 'textColor' => The hex color code of the button text, must include the leading '#'. 'backgroundColor' => The hex color code of the button background, must include the leading '#'.
protected $button

$containerBackgroundColor protected_oe property

The hex color code of the container background, must include the leading '#'.
protected $containerBackgroundColor

$defaultButtonBackgroundColor protected_oe property

The default hex color code of the button background, must include the leading '#'.
protected $defaultButtonBackgroundColor

$defaultButtonTextColor protected_oe property

The default hex color code of the button text, must include the leading '#'.
protected $defaultButtonTextColor

$image protected_oe property

An array representing an image with the following keys: 'source' => The image source url. 'link' => The href value of the image wrapper. 'alt' => The alt value of the image tag.
protected $image

$lead protected_oe property

The HTML formatted email lead (sub-title, appears under title).
protected $lead

$message protected_oe property

The HTML formatted email message (the body of the email).
protected $message

$plaintext protected_oe property

Whether to render in plaintext.
protected $plaintext

$textColor protected_oe property

The hex color code of the text, must include the leading '#'.
protected $textColor

$title protected_oe property

The HTML formatted email title.
protected $title

$view protected_oe property

The path to the email view.
protected $view