Skip to content

Commit

Permalink
formatting and changes
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 22, 2018
1 parent cf9945f commit a432d9e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 79 deletions.
4 changes: 0 additions & 4 deletions src/Illuminate/Mail/MailServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
45 changes: 24 additions & 21 deletions src/Illuminate/Mail/Mailable.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,21 @@
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;

class Mailable implements MailableContract, Renderable
{
use Localizable;

/**
* The locale of the message.
*
* @var string
*/
public $locale;

/**
* The person the message is from.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down
32 changes: 0 additions & 32 deletions src/Illuminate/Mail/Mailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
}
38 changes: 19 additions & 19 deletions src/Illuminate/Mail/PendingMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ class PendingMail
*/
protected $mailer;

/**
* The locale of the message.
*
* @var array
*/
protected $locale;

/**
* The "to" recipients of the message.
*
Expand All @@ -34,13 +41,6 @@ class PendingMail
*/
protected $bcc = [];

/**
* The locale of the message.
*
* @var array
*/
protected $locale;

/**
* Create a new mailable mailer instance.
*
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Illuminate/Translation/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit a432d9e

Please sign in to comment.