Jet\Application_Module_HasEmailTemplates_Interface

An application module can carry its own set of email templates, and this capability is utilized in the sample application.

To enable an application module to hold its own email templates, it must implement this interface and use the Application_Module_HasEmailTemplates_Trait trait.

Interface Description

Method Meaning
public getEmailTemplatesDir(
) : string
Specifies the path to the directory where email templates are stored.
public static createEmailTemplate(
string $template_id,
Locale $locale
) : Mailing_Email_Template
Prepares the specified email template instance.

Usage Example

namespace JetApplicationModule\REST\Auth\Entity;

......
class 
APIUser extends DataModel implements Auth_APIUser
{

    .....
    public function 
sendWelcomeEmail( string $password ): void
    
{
        
$email_template = Main::createEmailTemplate(
            
template_id: 'welcome',
            
locale: $this->getLocale()
        );

        
$email_template->setVar( 'user', $this );
        
$email_template->setVar( 'password', $password );

        
$email = $email_template->getEmail();
        
$email->setTo( $this->getEmail() );
        
$email->send();

    }
    .....
}
Previous chapter
Jet\Mailing_Email_File
Next chapter
Jet\Application_Module_HasEmailTemplates_Trait