Skip to content

Commit a432d9e

Browse files
committed
formatting and changes
1 parent cf9945f commit a432d9e

File tree

5 files changed

+46
-79
lines changed

5 files changed

+46
-79
lines changed

src/Illuminate/Mail/MailServiceProvider.php

-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ protected function registerIlluminateMailer()
5252
$mailer->setQueue($app['queue']);
5353
}
5454

55-
if ($app->bound('translator')) {
56-
$mailer->setTranslator($app['translator']);
57-
}
58-
5955
// Next we will set all of the global addresses on this mailer, which allows
6056
// for easy unification of all "from" addresses as well as easy debugging
6157
// of sent messages since they get be sent into a single email address.

src/Illuminate/Mail/Mailable.php

+24-21
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,21 @@
1212
use Illuminate\Support\Traits\Localizable;
1313
use Illuminate\Contracts\Support\Renderable;
1414
use Illuminate\Contracts\Queue\Factory as Queue;
15+
use Illuminate\Contracts\Translation\Translator;
1516
use Illuminate\Contracts\Mail\Mailer as MailerContract;
1617
use Illuminate\Contracts\Mail\Mailable as MailableContract;
1718

1819
class Mailable implements MailableContract, Renderable
1920
{
2021
use Localizable;
2122

23+
/**
24+
* The locale of the message.
25+
*
26+
* @var string
27+
*/
28+
public $locale;
29+
2230
/**
2331
* The person the message is from.
2432
*
@@ -54,13 +62,6 @@ class Mailable implements MailableContract, Renderable
5462
*/
5563
public $replyTo = [];
5664

57-
/**
58-
* The locale of the message.
59-
*
60-
* @var string
61-
*/
62-
public $locale;
63-
6465
/**
6566
* The subject of the message.
6667
*
@@ -132,7 +133,9 @@ class Mailable implements MailableContract, Renderable
132133
*/
133134
public function send(MailerContract $mailer)
134135
{
135-
$this->withLocale($this->locale, $mailer->translator, function () use ($mailer) {
136+
$translator = Container::getInstance()->make(Translator::class);
137+
138+
$this->withLocale($this->locale, $translator, function () use ($mailer) {
136139
Container::getInstance()->call([$this, 'build']);
137140

138141
$mailer->send($this->buildView(), $this->buildViewData(), function ($message) {
@@ -362,6 +365,19 @@ protected function runCallbacks($message)
362365
return $this;
363366
}
364367

368+
/**
369+
* Set the locale of the message.
370+
*
371+
* @param string $locale
372+
* @return $this
373+
*/
374+
public function locale($locale)
375+
{
376+
$this->locale = $locale;
377+
378+
return $this;
379+
}
380+
365381
/**
366382
* Set the priority of this message.
367383
*
@@ -584,19 +600,6 @@ protected function hasRecipient($address, $name = null, $property = 'to')
584600
});
585601
}
586602

587-
/**
588-
* Set the locale of the message.
589-
*
590-
* @param string $locale
591-
* @return $this
592-
*/
593-
public function locale($locale)
594-
{
595-
$this->locale = $locale;
596-
597-
return $this;
598-
}
599-
600603
/**
601604
* Set the subject of the message.
602605
*

src/Illuminate/Mail/Mailer.php

-32
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Illuminate\Contracts\Queue\Factory as QueueContract;
1515
use Illuminate\Contracts\Mail\Mailable as MailableContract;
1616
use Illuminate\Contracts\Mail\MailQueue as MailQueueContract;
17-
use Illuminate\Contracts\Translation\Translator as TranslatorContract;
1817

1918
class Mailer implements MailerContract, MailQueueContract
2019
{
@@ -69,13 +68,6 @@ class Mailer implements MailerContract, MailQueueContract
6968
*/
7069
protected $queue;
7170

72-
/**
73-
* The translator implementation.
74-
*
75-
* @var \Illuminate\Contracts\Translation\Translator
76-
*/
77-
public $translator;
78-
7971
/**
8072
* Array of failed recipients.
8173
*
@@ -156,17 +148,6 @@ public function bcc($users)
156148
return (new PendingMail($this))->bcc($users);
157149
}
158150

159-
/**
160-
* Begin the process of mailing a mailable class instance.
161-
*
162-
* @param string $locale
163-
* @return \Illuminate\Mail\PendingMail
164-
*/
165-
public function locale($locale)
166-
{
167-
return (new PendingMail($this))->locale($locale);
168-
}
169-
170151
/**
171152
* Send a new message with only an HTML part.
172153
*
@@ -585,17 +566,4 @@ public function setQueue(QueueContract $queue)
585566

586567
return $this;
587568
}
588-
589-
/**
590-
* Set the translator instance.
591-
*
592-
* @param \Illuminate\Contracts\Translation\Translator $translator
593-
* @return $this
594-
*/
595-
public function setTranslator(TranslatorContract $translator)
596-
{
597-
$this->translator = $translator;
598-
599-
return $this;
600-
}
601569
}

src/Illuminate/Mail/PendingMail.php

+19-19
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ class PendingMail
1313
*/
1414
protected $mailer;
1515

16+
/**
17+
* The locale of the message.
18+
*
19+
* @var array
20+
*/
21+
protected $locale;
22+
1623
/**
1724
* The "to" recipients of the message.
1825
*
@@ -34,13 +41,6 @@ class PendingMail
3441
*/
3542
protected $bcc = [];
3643

37-
/**
38-
* The locale of the message.
39-
*
40-
* @var array
41-
*/
42-
protected $locale;
43-
4444
/**
4545
* Create a new mailable mailer instance.
4646
*
@@ -53,14 +53,14 @@ public function __construct(Mailer $mailer)
5353
}
5454

5555
/**
56-
* Set the recipients of the message.
56+
* Set the locale of the message.
5757
*
58-
* @param mixed $users
58+
* @param string $locale
5959
* @return $this
6060
*/
61-
public function to($users)
61+
public function locale($locale)
6262
{
63-
$this->to = $users;
63+
$this->locale = $locale;
6464

6565
return $this;
6666
}
@@ -71,9 +71,9 @@ public function to($users)
7171
* @param mixed $users
7272
* @return $this
7373
*/
74-
public function cc($users)
74+
public function to($users)
7575
{
76-
$this->cc = $users;
76+
$this->to = $users;
7777

7878
return $this;
7979
}
@@ -84,22 +84,22 @@ public function cc($users)
8484
* @param mixed $users
8585
* @return $this
8686
*/
87-
public function bcc($users)
87+
public function cc($users)
8888
{
89-
$this->bcc = $users;
89+
$this->cc = $users;
9090

9191
return $this;
9292
}
9393

9494
/**
95-
* Set the locale of the message.
95+
* Set the recipients of the message.
9696
*
97-
* @param string $locale
97+
* @param mixed $users
9898
* @return $this
9999
*/
100-
public function locale($locale)
100+
public function bcc($users)
101101
{
102-
$this->locale = $locale;
102+
$this->bcc = $users;
103103

104104
return $this;
105105
}

src/Illuminate/Translation/Translator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -478,12 +478,12 @@ public function setFallback($fallback)
478478
}
479479

480480
/**
481-
* Set loaded translation groups.
481+
* Set the loaded translation groups.
482482
*
483-
* @param string $fallback
483+
* @param array $loaded
484484
* @return void
485485
*/
486-
public function setLoaded($loaded)
486+
public function setLoaded(array $loaded)
487487
{
488488
$this->loaded = $loaded;
489489
}

0 commit comments

Comments
 (0)