Yii Framework Forum: How can I override a mail view of a package? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How can I override a mail view of a package?

#1 User is offline   leviathan 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 28-March 12

Posted 26 November 2014 - 06:05 AM

I am trying to override the passwordResetToken view in the rogbregonm/yii2-auth package (github.com/robregonm/yii2-auth), which is used to send an email to the user.

The view is located in vendor/robregonm/yii2-auth/views/mail/passwordResetToken.php and the view I want to use is in frontend/themes/liva/vendor/auth/mail/passwordResetToken.php

I tried it in the main frontend configuration (advanced template):

(...)
'view' => [
    'theme' => [
        'pathMap' => [
            '@frontend/views'                   => '@frontend/themes/liva',
            '@vendor/robregonm/yii2-auth/views' => '@frontend/themes/liva/vendor/auth',
        ],
        'baseUrl' => '@web/themes/liva',
    ],
],
(...)


This works fine for the views in the default folder of the package, but the mail view is ignored. It always sends the view from the package.

I also tried:

'@auth/views' => '@frontend/themes/liva/vendor/auth'

and

'@auth/views/mail/passwordResetToken' => '@frontend/themes/liva/vendor/auth/mail/passwordResetToken'


The code that sends the mail:

return \Yii::$app->mailer->compose('@auth/views/mail/passwordResetToken', ['user' => $user])
                         ->setFrom([\Yii::$app->getModule('auth')->supportEmail => \Yii::$app->name])
                         ->setTo($this->email)
                         ->setSubject(Yii::t('auth.reset-password', 'Password reset for {name}', ['name' => \Yii::$app->name]))
                         ->send();


Is there something wrong with my approach? Or another way to override the view?
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users