Skip to content

Commit 5f78c90

Browse files
committed
check for view existence first
1 parent 58dc491 commit 5f78c90

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/Illuminate/Mail/Markdown.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ public function render($view, array $data = [], $inliner = null)
6363
'mail', $this->htmlComponentPaths()
6464
)->make($view, $data)->render();
6565

66-
$theme = Str::contains($this->theme, '::')
67-
? $this->theme
68-
: 'mail::themes.'.$this->theme;
66+
if ($this->view->exists($this->theme)) {
67+
$theme = $this->theme;
68+
} else {
69+
$theme = Str::contains($this->theme, '::')
70+
? $this->theme
71+
: 'mail::themes.'.$this->theme;
72+
}
6973

7074
return new HtmlString(($inliner ?: new CssToInlineStyles)->convert(
7175
$contents, $this->view->make($theme, $data)->render()

tests/Mail/MailMarkdownTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function testRenderFunctionReturnsHtml()
2020
$markdown = new Markdown($viewFactory);
2121
$viewFactory->shouldReceive('flushFinderCache')->once();
2222
$viewFactory->shouldReceive('replaceNamespace')->once()->with('mail', $markdown->htmlComponentPaths())->andReturnSelf();
23+
$viewFactory->shouldReceive('exists')->with('default')->andReturn(false);
2324
$viewFactory->shouldReceive('make')->with('view', [])->andReturnSelf();
2425
$viewFactory->shouldReceive('make')->with('mail::themes.default', [])->andReturnSelf();
2526
$viewFactory->shouldReceive('render')->twice()->andReturn('<html></html>', 'body {}');
@@ -36,8 +37,9 @@ public function testRenderFunctionReturnsHtmlWithCustomTheme()
3637
$markdown->theme('yaz');
3738
$viewFactory->shouldReceive('flushFinderCache')->once();
3839
$viewFactory->shouldReceive('replaceNamespace')->once()->with('mail', $markdown->htmlComponentPaths())->andReturnSelf();
40+
$viewFactory->shouldReceive('exists')->with('yaz')->andReturn(true);
3941
$viewFactory->shouldReceive('make')->with('view', [])->andReturnSelf();
40-
$viewFactory->shouldReceive('make')->with('mail::themes.yaz', [])->andReturnSelf();
42+
$viewFactory->shouldReceive('make')->with('yaz', [])->andReturnSelf();
4143
$viewFactory->shouldReceive('render')->twice()->andReturn('<html></html>', 'body {}');
4244

4345
$result = $markdown->render('view', []);

0 commit comments

Comments
 (0)