public function renderEmailBody(string $templateName, string $templatePackage, string $format, array $variables, bool $emogrify = true): string
    {
        $standaloneView = new StandaloneView();
        $request = $standaloneView->getRequest();
        //        $request->setControllerPackageKey('Sandstorm.Maklerapp'); TODO needed?
        $request->setFormat($format);

        $templatePath = sprintf('resource://%s/Private/EmailTemplates/', $templatePackage);
        $templatePathAndFilename = sprintf('%s%s.%s', $templatePath, $templateName, $format);
        $standaloneView->setTemplatePathAndFilename($templatePathAndFilename);
        $standaloneView->setLayoutRootPath($templatePath . 'Layouts');
        $standaloneView->setPartialRootPath($templatePath . 'Partials');
        $standaloneView->assignMultiple($variables);
        $emailBody = $standaloneView->render();

        // Emogrify - this will inline any styles in the HTML for proper display in Gmail.
        $emogrifiedFormats = ['htm', 'html'];
        if ($emogrify && in_array($format, $emogrifiedFormats)) {
            $emogrifier = new Emogrifier($emailBody);
            $emailBody = $emogrifier->emogrify();
        }

        return $emailBody;
    }
public function renderEmailBody(string $templateName, string $templatePackage, string $format, array $variables, bool $emogrify = true): string
    {
        $standaloneView = new StandaloneView();
        $request = $standaloneView->getRequest();
        //        $request->setControllerPackageKey('Sandstorm.Maklerapp'); TODO needed?
        $request->setFormat($format);

        $templatePath = sprintf('resource://%s/Private/EmailTemplates/', $templatePackage);
        $templatePathAndFilename = sprintf('%s%s.%s', $templatePath, $templateName, $format);
        $standaloneView->setTemplatePathAndFilename($templatePathAndFilename);
        $standaloneView->setLayoutRootPath($templatePath . 'Layouts');
        $standaloneView->setPartialRootPath($templatePath . 'Partials');
        $standaloneView->assignMultiple($variables);
        $emailBody = $standaloneView->render();

        // Emogrify - this will inline any styles in the HTML for proper display in Gmail.
        $emogrifiedFormats = ['htm', 'html'];
        if ($emogrify && in_array($format, $emogrifiedFormats)) {
            $emogrifier = new Emogrifier($emailBody);
            $emailBody = $emogrifier->emogrify();
        }

        return $emailBody;
    }
public function renderEmailBody ( string $ templateName , string $ templatePackage , string $ format , array $ variables , bool $ emogrify = true ) : string { $ standaloneView = new StandaloneView ( ) ; $ request = $ standaloneView -> getRequest ( ) ; //        $request->setControllerPackageKey('Sandstorm.Maklerapp'); TODO needed? $ request -> setFormat ( $ format ) ; $ templatePath = sprintf ( 'resource://%s/Private/EmailTemplates/' , $ templatePackage ) ; $ templatePathAndFilename = sprintf ( '%s%s.%s' , $ templatePath , $ templateName , $ format ) ; $ standaloneView -> setTemplatePathAndFilename ( $ templatePathAndFilename ) ; $ standaloneView -> setLayoutRootPath ( $ templatePath . 'Layouts' ) ; $ standaloneView -> setPartialRootPath ( $ templatePath . 'Partials' ) ; $ standaloneView -> assignMultiple ( $ variables ) ; $ emailBody = $ standaloneView -> render ( ) ; // Emogrify - this will inline any styles in the HTML for proper display in Gmail. $ emogrifiedFormats = [ 'htm' , 'html' ] ; if ( $ emogrify && in_array ( $ format , $ emogrifiedFormats ) ) { $ emogrifier = new Emogrifier ( $ emailBody ) ; $ emailBody = $ emogrifier -> emogrify ( ) ; } return $ emailBody ; }
Renders the email body of a template. Can be used directly to only render the email html body.
if the given format is htm or html, will automatically emogrify the email body.
This can be skipped by setting the last parameter to false.

@param string $templateName
@param string $templateName
@param string $format
@param array $variables
@param bool $emogrify
@return string
Renders the email body of a template . Can be used directly to only render the email html body . if the given format is htm or html will automatically emogrify the email body . This can be skipped by setting the last parameter to false .