Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse order in checking mail config styles #107

Merged
merged 3 commits into from
Oct 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/Mail/MailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Overrides the Laravel MailManager
* - Replaces the Laravel Mailer class with the Winter Mailer class
* - Fires mailer.beforeRegister & mailer.register events
* - Uses another method to determine old vs. new mail configs
*/
class MailManager extends BaseMailManager
{
Expand Down Expand Up @@ -71,4 +72,29 @@ protected function resolve($name)

return $mailer;
}

/**
* @inheritDoc
*/
protected function getConfig(string $name)
{
// Here we will check if the "mailers" key exists and if it does, we will use that to
// determine the applicable config. Laravel checks if the "drivers" key exists, and while
// that does work for Laravel, it doesn't work in Winter when someone uses the Backend to
// populate mail settings, as these mail settings are populated into the "mailers" key.
return $this->app['config']['mail.mailers']
? ($this->app['config']["mail.mailers.{$name}"] ?? $this->app['config']['mail'])
: $this->app['config']['mail'];
}

/**
* @inheritDoc
*/
public function getDefaultDriver()
{
// We will do the reverse of what Laravel does and check for "default" first, which is
// populated by the Backend or the new "mail" config, before searching for the "driver"
// key that was present in older version of Winter (<1.2).
return $this->app['config']['mail.default'] ?? $this->app['config']['mail.driver'];
}
}