Fix #18955: Check yiisoft/yii2-swiftmailer before using as default mailer in yii\base\Application

This commit is contained in:
Anton
2021-10-20 11:10:20 +03:00
committed by GitHub
parent 685b38c50f
commit d80974da30
2 changed files with 10 additions and 4 deletions

View File

@ -24,6 +24,7 @@ Yii Framework 2 Change Log
- Enh #18904: Improve Captcha client-side validation (hexkir) - Enh #18904: Improve Captcha client-side validation (hexkir)
- Bug #18913: Add filename validation for `MessageSource::getMessageFilePath()` (uaoleg) - Bug #18913: Add filename validation for `MessageSource::getMessageFilePath()` (uaoleg)
- Bug #18909: Fix bug with binding default action parameters for controllers (bizley) - Bug #18909: Fix bug with binding default action parameters for controllers (bizley)
- Bug #18955: Check `yiisoft/yii2-swiftmailer` before using as default mailer in `yii\base\Application` (WinterSilence)
2.0.43 August 09, 2021 2.0.43 August 09, 2021

View File

@ -589,6 +589,7 @@ abstract class Application extends Module
/** /**
* Returns the mailer component. * Returns the mailer component.
* @return \yii\mail\MailerInterface the mailer application component. * @return \yii\mail\MailerInterface the mailer application component.
* @throws InvalidConfigException If this component is not configured.
*/ */
public function getMailer() public function getMailer()
{ {
@ -597,8 +598,7 @@ abstract class Application extends Module
/** /**
* Returns the auth manager for this application. * Returns the auth manager for this application.
* @return \yii\rbac\ManagerInterface the auth manager application component. * @return \yii\rbac\ManagerInterface|null the auth manager application component or null if it's not configured.
* Null is returned if auth manager is not configured.
*/ */
public function getAuthManager() public function getAuthManager()
{ {
@ -625,20 +625,25 @@ abstract class Application extends Module
/** /**
* Returns the configuration of core application components. * Returns the configuration of core application components.
* @return array
* @see set() * @see set()
*/ */
public function coreComponents() public function coreComponents()
{ {
return [ $components = [
'log' => ['class' => 'yii\log\Dispatcher'], 'log' => ['class' => 'yii\log\Dispatcher'],
'view' => ['class' => 'yii\web\View'], 'view' => ['class' => 'yii\web\View'],
'formatter' => ['class' => 'yii\i18n\Formatter'], 'formatter' => ['class' => 'yii\i18n\Formatter'],
'i18n' => ['class' => 'yii\i18n\I18N'], 'i18n' => ['class' => 'yii\i18n\I18N'],
'mailer' => ['class' => 'yii\swiftmailer\Mailer'],
'urlManager' => ['class' => 'yii\web\UrlManager'], 'urlManager' => ['class' => 'yii\web\UrlManager'],
'assetManager' => ['class' => 'yii\web\AssetManager'], 'assetManager' => ['class' => 'yii\web\AssetManager'],
'security' => ['class' => 'yii\base\Security'], 'security' => ['class' => 'yii\base\Security'],
]; ];
if (class_exists('yii\swiftmailer\Mailer')) {
$components['mailer'] = ['class' => 'yii\swiftmailer\Mailer'];
}
return $components;
} }
/** /**