Final Class common\bootstrap\MailerBootstrap

Inheritancecommon\bootstrap\MailerBootstrap
Implementsyii\base\BootstrapInterface
Source Code https://github.com/yiisoft/yii2-app-advanced/blob/master/common/bootstrap/MailerBootstrap.php

Registers the application mailer component as the DI container singleton for {@see MailerInterface}.

Codeception replaces components.mailer with its own TestMailer to capture sent emails.

Since the DI container is configured before the mailer mock, this bootstrap ensures the DI singleton resolves to the same mailer instance used by the application.

Public Methods

Hide inherited methods

Method Description Defined By
bootstrap() common\bootstrap\MailerBootstrap

Method Details

Hide inherited methods

bootstrap() public method

public void bootstrap ( \yii\base\Application $app )
$app \yii\base\Application

Application instance.

                public function bootstrap($app): void
{
    Yii::$container->setSingleton(MailerInterface::class, $app->mailer);
}