diff --git a/src/Illuminate/Mail/MailServiceProvider.php b/src/Illuminate/Mail/MailServiceProvider.php index b07d8408f454..4be6bfd52250 100755 --- a/src/Illuminate/Mail/MailServiceProvider.php +++ b/src/Illuminate/Mail/MailServiceProvider.php @@ -52,10 +52,6 @@ protected function registerIlluminateMailer() $mailer->setQueue($app['queue']); } - if ($app->bound('translator')) { - $mailer->setTranslator($app['translator']); - } - // Next we will set all of the global addresses on this mailer, which allows // for easy unification of all "from" addresses as well as easy debugging // of sent messages since they get be sent into a single email address. diff --git a/src/Illuminate/Mail/Mailable.php b/src/Illuminate/Mail/Mailable.php index 9dfe01876321..81a7c3fb9842 100644 --- a/src/Illuminate/Mail/Mailable.php +++ b/src/Illuminate/Mail/Mailable.php @@ -12,6 +12,7 @@ use Illuminate\Support\Traits\Localizable; use Illuminate\Contracts\Support\Renderable; use Illuminate\Contracts\Queue\Factory as Queue; +use Illuminate\Contracts\Translation\Translator; use Illuminate\Contracts\Mail\Mailer as MailerContract; use Illuminate\Contracts\Mail\Mailable as MailableContract; @@ -19,6 +20,13 @@ class Mailable implements MailableContract, Renderable { use Localizable; + /** + * The locale of the message. + * + * @var string + */ + public $locale; + /** * The person the message is from. * @@ -54,13 +62,6 @@ class Mailable implements MailableContract, Renderable */ public $replyTo = []; - /** - * The locale of the message. - * - * @var string - */ - public $locale; - /** * The subject of the message. * @@ -132,7 +133,9 @@ class Mailable implements MailableContract, Renderable */ public function send(MailerContract $mailer) { - $this->withLocale($this->locale, $mailer->translator, function () use ($mailer) { + $translator = Container::getInstance()->make(Translator::class); + + $this->withLocale($this->locale, $translator, function () use ($mailer) { Container::getInstance()->call([$this, 'build']); $mailer->send($this->buildView(), $this->buildViewData(), function ($message) { @@ -362,6 +365,19 @@ protected function runCallbacks($message) return $this; } + /** + * Set the locale of the message. + * + * @param string $locale + * @return $this + */ + public function locale($locale) + { + $this->locale = $locale; + + return $this; + } + /** * Set the priority of this message. * @@ -584,19 +600,6 @@ protected function hasRecipient($address, $name = null, $property = 'to') }); } - /** - * Set the locale of the message. - * - * @param string $locale - * @return $this - */ - public function locale($locale) - { - $this->locale = $locale; - - return $this; - } - /** * Set the subject of the message. * diff --git a/src/Illuminate/Mail/Mailer.php b/src/Illuminate/Mail/Mailer.php index 84e4b767de32..a3d1c7ff2ac3 100755 --- a/src/Illuminate/Mail/Mailer.php +++ b/src/Illuminate/Mail/Mailer.php @@ -14,7 +14,6 @@ use Illuminate\Contracts\Queue\Factory as QueueContract; use Illuminate\Contracts\Mail\Mailable as MailableContract; use Illuminate\Contracts\Mail\MailQueue as MailQueueContract; -use Illuminate\Contracts\Translation\Translator as TranslatorContract; class Mailer implements MailerContract, MailQueueContract { @@ -69,13 +68,6 @@ class Mailer implements MailerContract, MailQueueContract */ protected $queue; - /** - * The translator implementation. - * - * @var \Illuminate\Contracts\Translation\Translator - */ - public $translator; - /** * Array of failed recipients. * @@ -156,17 +148,6 @@ public function bcc($users) return (new PendingMail($this))->bcc($users); } - /** - * Begin the process of mailing a mailable class instance. - * - * @param string $locale - * @return \Illuminate\Mail\PendingMail - */ - public function locale($locale) - { - return (new PendingMail($this))->locale($locale); - } - /** * Send a new message with only an HTML part. * @@ -585,17 +566,4 @@ public function setQueue(QueueContract $queue) return $this; } - - /** - * Set the translator instance. - * - * @param \Illuminate\Contracts\Translation\Translator $translator - * @return $this - */ - public function setTranslator(TranslatorContract $translator) - { - $this->translator = $translator; - - return $this; - } } diff --git a/src/Illuminate/Mail/PendingMail.php b/src/Illuminate/Mail/PendingMail.php index eebb93c46203..f518c2cc7931 100644 --- a/src/Illuminate/Mail/PendingMail.php +++ b/src/Illuminate/Mail/PendingMail.php @@ -13,6 +13,13 @@ class PendingMail */ protected $mailer; + /** + * The locale of the message. + * + * @var array + */ + protected $locale; + /** * The "to" recipients of the message. * @@ -34,13 +41,6 @@ class PendingMail */ protected $bcc = []; - /** - * The locale of the message. - * - * @var array - */ - protected $locale; - /** * Create a new mailable mailer instance. * @@ -53,14 +53,14 @@ public function __construct(Mailer $mailer) } /** - * Set the recipients of the message. + * Set the locale of the message. * - * @param mixed $users + * @param string $locale * @return $this */ - public function to($users) + public function locale($locale) { - $this->to = $users; + $this->locale = $locale; return $this; } @@ -71,9 +71,9 @@ public function to($users) * @param mixed $users * @return $this */ - public function cc($users) + public function to($users) { - $this->cc = $users; + $this->to = $users; return $this; } @@ -84,22 +84,22 @@ public function cc($users) * @param mixed $users * @return $this */ - public function bcc($users) + public function cc($users) { - $this->bcc = $users; + $this->cc = $users; return $this; } /** - * Set the locale of the message. + * Set the recipients of the message. * - * @param string $locale + * @param mixed $users * @return $this */ - public function locale($locale) + public function bcc($users) { - $this->locale = $locale; + $this->bcc = $users; return $this; } diff --git a/src/Illuminate/Translation/Translator.php b/src/Illuminate/Translation/Translator.php index 9444e747b24f..6faf6b31c40a 100755 --- a/src/Illuminate/Translation/Translator.php +++ b/src/Illuminate/Translation/Translator.php @@ -478,12 +478,12 @@ public function setFallback($fallback) } /** - * Set loaded translation groups. + * Set the loaded translation groups. * - * @param string $fallback + * @param array $loaded * @return void */ - public function setLoaded($loaded) + public function setLoaded(array $loaded) { $this->loaded = $loaded; }