Conditions | 5 |
Paths | 9 |
Total Lines | 31 |
Code Lines | 20 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | public function run() |
||
15 | { |
||
16 | // Default to this view file |
||
17 | $viewFilePath = '@app/views/mail/en-US/' . $this->viewFile . '.twig'; |
||
18 | |||
19 | // Scan the "Accept-Language" header to see if we have a better viewfile |
||
20 | foreach ($this->locales as $language) { |
||
21 | $vfp = '@app/views/mail/' . $language . '/' . $viewFile . '.twig'; |
||
|
|||
22 | if (\file_exists(Yii::getAlias($vfp))) { |
||
23 | $viewFilePath = $vfp; |
||
24 | break; |
||
25 | } |
||
26 | } |
||
27 | |||
28 | if (!\file_exists(Yii::getAlias($viewFilePath))) { |
||
29 | Yii::warning(sprintf('The requested view (%s) file does not exist', $viewFilePath)); |
||
30 | return false; |
||
31 | } |
||
32 | |||
33 | $view = Yii::$app->view->renderFile($viewFilePath, $this->viewParams); |
||
34 | try { |
||
35 | return Yii::$app->mailer->compose() |
||
36 | ->setFrom(Yii::$app->yrc->fromEmail) |
||
37 | ->setTo($this->destination) |
||
38 | ->setSubject($this->subject) |
||
39 | ->setHtmlBody($view) |
||
40 | ->send(); |
||
41 | } catch (\Exception $e) { |
||
42 | return false; |
||
43 | } |
||
44 | } |
||
45 | } |
This check looks for variables that are accessed but have not been defined. It raises an issue if it finds another variable that has a similar name.
The variable may have been renamed without also renaming all references.