-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial work on support Symfony Mail
- Loading branch information
1 parent
66c16d4
commit d952ab5
Showing
7 changed files
with
75 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php namespace Winter\Storm\Mail; | ||
|
||
use InvalidArgumentException; | ||
use Illuminate\Mail\MailManager as BaseMailManager; | ||
|
||
/** | ||
* Overrides the Laravel MailManager | ||
* - Replaces the Laravel Mailer class with the Winter Mailer class | ||
* - Fires mailer.beforeRegister & mailer.register events | ||
*/ | ||
class MailManager extends BaseMailManager | ||
{ | ||
/** | ||
* Resolve the given mailer. | ||
* | ||
* @param string $name | ||
* @return \Winter\Storm\Mail\Mailer | ||
* | ||
* @throws \InvalidArgumentException | ||
*/ | ||
protected function resolve($name) | ||
{ | ||
$config = $this->getConfig($name); | ||
|
||
if (is_null($config)) { | ||
throw new InvalidArgumentException("Mailer [{$name}] is not defined."); | ||
} | ||
|
||
/* | ||
* Extensibility | ||
*/ | ||
$this->app['events']->fire('mailer.beforeRegister', [$this]); | ||
|
||
// Once we have created the mailer instance we will set a container instance | ||
// on the mailer. This allows us to resolve mailer classes via containers | ||
// for maximum testability on said classes instead of passing Closures. | ||
$mailer = new Mailer( | ||
$name, | ||
$this->app['view'], | ||
$this->createSymfonyTransport($config), | ||
$this->app['events'] | ||
); | ||
|
||
if ($this->app->bound('queue')) { | ||
$mailer->setQueue($this->app['queue']); | ||
} | ||
|
||
// 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 these will be sent to a single email address. | ||
foreach (['from', 'reply_to', 'to', 'return_path'] as $type) { | ||
$this->setGlobalAddress($mailer, $config, $type); | ||
} | ||
|
||
/* | ||
* Extensibility | ||
*/ | ||
$this->app['events']->fire('mailer.register', [$this, $mailer]); | ||
|
||
return $mailer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.