add Closure support for fromEmail (#274)

This commit is contained in:
bscheshirwork
2018-10-23 12:05:53 +03:00
committed by Lorenzo Milesi
parent 16bd448042
commit eaa6bf967f
3 changed files with 54 additions and 3 deletions

View File

@ -118,7 +118,7 @@ class MailFactory
* Builds a MailerService.
*
* @param string $type
* @param string $from
* @param string|array|\Closure $from
* @param string $to
* @param string $subject
* @param string $view
@ -130,6 +130,9 @@ class MailFactory
*/
public static function makeMailerService($type, $from, $to, $subject, $view, $params = [])
{
if ($from instanceof \Closure){
$from = $from($type);
}
/** @noinspection PhpIncompatibleReturnTypeInspection */
return Yii::$container->get(
MailService::class,