Newscoop\Services\TemplatesService::fetchTemplate PHP Method

fetchTemplate() public method

Fetch template with smarty
public fetchTemplate ( string $file, array $params = [], integer $lifetime = 1400 ) : string
$file string template file path
$params array array with template parameters
$lifetime integer template cache lifetime (default: 1400 seconds)
return string Template output
    public function fetchTemplate($file, $params = array(), $lifetime = 1400)
    {
        $content = $this->renderTemplate($file, $params, $lifetime, false);
        $this->preconfigureVector();
        return $content;
    }

Usage Example

 private function loadProperMessageTemplateBy($code)
 {
     switch ($code) {
         case Emails::USER_CONFIRMATION:
             $message = $this->templatesService->fetchTemplate("_paywall/email_notify_user.tpl");
             break;
         case Emails::SUBSCRIPTION_CONFIRMATION:
             $message = $this->templatesService->fetchTemplate("_paywall/email_notify_admin.tpl");
             break;
         case Emails::SUBSCRIPTION_STATUS:
             $message = $this->templatesService->fetchTemplate("_paywall/email_subscription_status.tpl");
             break;
         case Emails::SUBSCRIPTION_EXPIRATION:
             $message = $this->templatesService->fetchTemplate("_paywall/email_subscription_expiration.tpl");
             break;
         case Emails::ADMIN_CREATED_CONFIRMATION:
             $message = $this->templatesService->fetchTemplate("_paywall/email_subscription_admin_created.tpl");
             break;
         default:
             break;
     }
     return $message;
 }