Templates_Registry
in package
Registry for email templates.
Table of Contents
- $templates : array<string|int, Template>
- List of registered templates.
- get_all() : array<string|int, mixed>
- Retrieve all registered templates.
- get_by_name() : Template|null
- Retrieve a template by its name.
- get_by_slug() : Template|null
- Retrieve a template by its slug.
- initialize() : void
- Initialize the template registry.
- register() : void
- Register a template instance in the registry.
Properties
$templates
List of registered templates.
private
array<string|int, Template>
$templates
= array()
Methods
get_all()
Retrieve all registered templates.
public
get_all() : array<string|int, mixed>
Return values
array<string|int, mixed> — List of all registered templates.get_by_name()
Retrieve a template by its name.
public
get_by_name(string $name) : Template|null
Example: get_by_name( 'mailpoet//email-general' ) will return the instance of Template with identical name.
Parameters
- $name : string
-
The name of the template.
Return values
Template|null — The template object or null if not found.get_by_slug()
Retrieve a template by its slug.
public
get_by_slug(string $slug) : Template|null
Example: get_by_slug( 'email-general' ) will return the instance of Template with identical slug.
Parameters
- $slug : string
-
The slug of the template.
Return values
Template|null — The template object or null if not found.initialize()
Initialize the template registry.
public
initialize() : void
This method should be called only once.
Return values
void —register()
Register a template instance in the registry.
public
register(Template $template) : void
Parameters
- $template : Template
-
The template to register.