Skip to content

Commit b982fc2

Browse files
committed
🔨 improve the mail_view() function
Signed-off-by: otengkwame <[email protected]>
1 parent 22a6dcb commit b982fc2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Core/helpers/plate_helper.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function view($view_path, $view_data = [], $return = false)
4646
$view_path = dot2slash($view_path);
4747

4848
if (config('view')['view_engine'] === '') {
49-
return ci()->load->view($view_path, $view_data, $return);
49+
return app()->use->view($view_path, $view_data, $return);
5050
}
5151

5252
// Get the evaluated view contents for the given plates view
@@ -121,18 +121,22 @@ function mail_view($mail_view_path, $mail_data)
121121
log_message('error', $exception_message);
122122
}
123123

124+
if (is_string($mail_view_path)) {
125+
return app()->use->view($mail_view_path, $mail_data, true);
126+
}
127+
124128
if ( ! is_array($mail_view_path)) {
125129
$exception_message = "Email view malformed, make sure it has the 'double colon' symbol '::' in it";
126130
throw new \Exception($exception_message);
127131
log_message('error', $exception_message);
128132
exit;
129133
}
130134

131-
$layout = $mail_view_path[0];
132-
$view = $mail_view_path[1];
135+
[$layout, $view] = $mail_view_path;
136+
133137
$mail_data = add_associative_array($mail_data, 'content', $view);
134138

135-
return ci()->load->view($layout, $mail_data, true);
139+
return app()->use->view($layout, $mail_data, true);
136140
}
137141
}
138142

0 commit comments

Comments
 (0)