EmailTemplate
extends BaseEntity
in package
EmailTemplate Entity
Templates are identified by slug. Use name/description for admin display.
Table of Contents
Properties
- $available_vars : array<string|int, mixed>|null
- $branch_id : int|null
- $created : DateTime|null
- $description : string|null
- $html_template : string|null
- $id : int
- $is_active : bool
- $modified : DateTime|null
- $name : string|null
- $slug : string|null
- $subject_template : string
- $text_template : string|null
- $variables_schema : array<string|int, mixed>|null
- $_accessible : array<string, bool>
- Fields that can be mass assigned using newEntity() or patchEntity().
Methods
- getBranchId() : int|null
- Get the branch ID for authorization checks.
- _getAvailableVars() : array<string|int, mixed>
- Getter for available_vars — always returns an array.
- _getDisplayName() : string
- Virtual display name: prefers name > slug.
- _getIsWorkflowNative() : bool
- Whether this template has a workflow-native slug identity.
- _getVariablesSchema() : array<string|int, mixed>
- Getter for variables_schema — always returns an array.
- _setAvailableVars() : array<string|int, mixed>|null
- Setter for available_vars — normalises to array before JSON storage.
- _setSlug() : string|null
- Normalise blank slugs to null so legacy templates do not participate in slug-based uniqueness checks.
- _setVariablesSchema() : array<string|int, mixed>|null
- Setter for variables_schema — normalises to array before JSON storage.
- _decodeJsonArray() : array<string|int, mixed>
- Decode a JSON string or passthrough an array, returning [] on failure.
- _normaliseAvailableVarEntries() : array<string|int, mixed>
- Normalize available_vars so legacy string lists and associative maps become a list of entries with an explicit `name` key.
- _normaliseJsonArray() : array<string|int, mixed>|null
- Normalise a value to an array for JSON column storage, returning null for empty input.
- _normaliseVariableSchemaEntries() : array<string|int, mixed>
- Normalize variables_schema so both supported shapes resolve to a list of entries with an explicit `name` key.
Properties
$available_vars
public
array<string|int, mixed>|null
$available_vars
$branch_id
public
int|null
$branch_id
Associated branch ID (when applicable)
$created
public
DateTime|null
$created
$description
public
string|null
$description
$html_template
public
string|null
$html_template
$id
public
int
$id
$is_active
public
bool
$is_active
$modified
public
DateTime|null
$modified
$name
public
string|null
$name
$slug
public
string|null
$slug
$subject_template
public
string
$subject_template
$text_template
public
string|null
$text_template
$variables_schema
public
array<string|int, mixed>|null
$variables_schema
$_accessible
Fields that can be mass assigned using newEntity() or patchEntity().
protected
array<string, bool>
$_accessible
= ['slug' => true, 'name' => true, 'description' => true, 'subject_template' => true, 'html_template' => true, 'text_template' => true, 'available_vars' => true, 'variables_schema' => true, 'is_active' => true, 'created' => false, 'modified' => false]
Methods
getBranchId()
Get the branch ID for authorization checks.
public
getBranchId() : int|null
Child classes should override for complex branch relationships.
Return values
int|null —The branch ID, or null if no association
_getAvailableVars()
Getter for available_vars — always returns an array.
protected
_getAvailableVars(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Return values
array<string|int, mixed>_getDisplayName()
Virtual display name: prefers name > slug.
protected
_getDisplayName() : string
Return values
string_getIsWorkflowNative()
Whether this template has a workflow-native slug identity.
protected
_getIsWorkflowNative() : bool
Return values
bool_getVariablesSchema()
Getter for variables_schema — always returns an array.
protected
_getVariablesSchema(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Return values
array<string|int, mixed>_setAvailableVars()
Setter for available_vars — normalises to array before JSON storage.
protected
_setAvailableVars(mixed $value) : array<string|int, mixed>|null
Parameters
- $value : mixed
Return values
array<string|int, mixed>|null_setSlug()
Normalise blank slugs to null so legacy templates do not participate in slug-based uniqueness checks.
protected
_setSlug(mixed $value) : string|null
Parameters
- $value : mixed
Return values
string|null_setVariablesSchema()
Setter for variables_schema — normalises to array before JSON storage.
protected
_setVariablesSchema(mixed $value) : array<string|int, mixed>|null
Parameters
- $value : mixed
Return values
array<string|int, mixed>|null_decodeJsonArray()
Decode a JSON string or passthrough an array, returning [] on failure.
private
_decodeJsonArray(mixed $value) : array<string|int, mixed>
Parameters
- $value : mixed
Return values
array<string|int, mixed>_normaliseAvailableVarEntries()
Normalize available_vars so legacy string lists and associative maps become a list of entries with an explicit `name` key.
private
_normaliseAvailableVarEntries(array<string|int, mixed> $entries) : array<string|int, mixed>
Supported inputs:
- ['memberScaName', 'memberViewUrl']
- [['name' => 'memberScaName', 'description' => '...']]
- ['memberScaName' => 'Member SCA Name']
Parameters
- $entries : array<string|int, mixed>
Return values
array<string|int, mixed>_normaliseJsonArray()
Normalise a value to an array for JSON column storage, returning null for empty input.
private
_normaliseJsonArray(mixed $value) : array<string|int, mixed>|null
Parameters
- $value : mixed
Return values
array<string|int, mixed>|null_normaliseVariableSchemaEntries()
Normalize variables_schema so both supported shapes resolve to a list of entries with an explicit `name` key.
private
_normaliseVariableSchemaEntries(array<string|int, mixed> $entries) : array<string|int, mixed>
Supported inputs:
- [['name' => 'foo', 'type' => 'string']]
- ['foo' => ['type' => 'string']]
Parameters
- $entries : array<string|int, mixed>