Winter CMS resources and help articles

Simple and to the point. Optimized by the community.

How to pass active locale/lang to mail templates data

0
by xyz.qtc, last modified on September 21st, 2022

use Event; use App; use System\Classes\MailManager; ...

public function boot()
{
                            Event::listen('mailer.beforeAddContent', function ($mailer, $message, $view, $data, $raw, $plain) {

            $data['_current_locale'] = !empty($data['_current_locale']) ? $data['_current_locale'] : App::getLocale();

            if (MailManager::instance()->addContentToMailer($message, $view, $data, $plain)) {
                // the caller who fired the event is expecting a FALSE response to halt the event
                return false;
            }

        }, 1);
    }

Discussion

0 comments

We use cookies to measure the performance of this website. Do you want to accept these cookies?