public function createEmailMessage($messageCode, $from, $to, $messageParameters = [], $locale = null, $cc = [], $bcc = [], $replyTo = [])
    {
        if (null !== $message = MessageQuery::getFromName($messageCode)) {
            if ($locale === null) {
                $locale = Lang::getDefaultLanguage()->getLocale();
            }

            $message->setLocale($locale);

            // Assign parameters
            foreach ($messageParameters as $name => $value) {
                $this->parser->assign($name, $value);
            }

            $this->parser->assign('locale', $locale);

            $instance = $this->getMessageInstance();

            $this->setupMessageHeaders($instance, $from, $to, $cc, $bcc, $replyTo);

            $message->buildMessage($this->parser, $instance);

            return $instance;
        }

        throw new \RuntimeException(
            Translator::getInstance()->trans(
                "Failed to load message with code '%code%', propably because it does'nt exists.",
                [ '%code%' => $messageCode ]
            )
        );
    }
public function createEmailMessage($messageCode, $from, $to, $messageParameters = [], $locale = null, $cc = [], $bcc = [], $replyTo = [])
    {
        if (null !== $message = MessageQuery::getFromName($messageCode)) {
            if ($locale === null) {
                $locale = Lang::getDefaultLanguage()->getLocale();
            }

            $message->setLocale($locale);

            // Assign parameters
            foreach ($messageParameters as $name => $value) {
                $this->parser->assign($name, $value);
            }

            $this->parser->assign('locale', $locale);

            $instance = $this->getMessageInstance();

            $this->setupMessageHeaders($instance, $from, $to, $cc, $bcc, $replyTo);

            $message->buildMessage($this->parser, $instance);

            return $instance;
        }

        throw new \RuntimeException(
            Translator::getInstance()->trans(
                "Failed to load message with code '%code%', propably because it does'nt exists.",
                [ '%code%' => $messageCode ]
            )
        );
    }
public function createEmailMessage ( $ messageCode , $ from , $ to , $ messageParameters = [ ] , $ locale = null , $ cc = [ ] , $ bcc = [ ] , $ replyTo = [ ] ) { if ( null !== $ message = MessageQuery :: getFromName ( $ messageCode ) ) { if ( $ locale === null ) { $ locale = Lang :: getDefaultLanguage ( ) -> getLocale ( ) ; } $ message -> setLocale ( $ locale ) ; // Assign parameters foreach ( $ messageParameters as $ name => $ value ) { $ this -> parser -> assign ( $ name , $ value ) ; } $ this -> parser -> assign ( 'locale' , $ locale ) ; $ instance = $ this -> getMessageInstance ( ) ; $ this -> setupMessageHeaders ( $ instance , $ from , $ to , $ cc , $ bcc , $ replyTo ) ; $ message -> buildMessage ( $ this -> parser , $ instance ) ; return $ instance ; } throw new \ RuntimeException ( Translator :: getInstance ( ) -> trans ( "Failed to load message with code '%code%', propably because it does'nt exists." , [ '%code%' => $ messageCode ] ) ) ; }
Create a SwiftMessage instance from a given message code.

@param  string $messageCode
@param  array  $from              From addresses. An array of (email-address => name)
@param  array  $to                To addresses. An array of (email-address => name)
@param  array  $messageParameters an array of (name => value) parameters that will be available in the message.
@param  string $locale            If null, the default store locale is used.
@param  array  $cc                Cc addresses. An array of (email-address => name) [optional]
@param  array  $bcc               Bcc addresses. An array of (email-address => name) [optional]
@param  array  $replyTo           Reply to addresses. An array of (email-address => name) [optional]

@return \Swift_Message the generated and built message.
@throws \SmartyException
Create a SwiftMessage instance from a given message code .