| 199 |
lars |
1 |
<?php namespace Clockwork\Helpers\Concerns;
|
|
|
2 |
|
|
|
3 |
use Clockwork\Helpers\StackFrame;
|
|
|
4 |
|
|
|
5 |
// Replaces the first stack frame rendering a Laravel view with a duplicate with a resolved original view path (instead
|
|
|
6 |
// of the compiled view path)
|
|
|
7 |
trait ResolvesViewName
|
|
|
8 |
{
|
|
|
9 |
public function resolveViewName()
|
|
|
10 |
{
|
|
|
11 |
$viewFrame = $this->first(function ($frame) {
|
|
|
12 |
return $frame->shortPath ? preg_match('#^/storage/framework/views/[a-z0-9]+\.php$#', $frame->shortPath) : false;
|
|
|
13 |
});
|
|
|
14 |
|
|
|
15 |
if (! $viewFrame) return $this;
|
|
|
16 |
|
|
|
17 |
$renderFrame = $this->first(function ($frame) {
|
|
|
18 |
return $frame->call == 'Illuminate\View\View->getContents()'
|
|
|
19 |
&& $frame->object instanceof \Illuminate\View\View;
|
|
|
20 |
});
|
|
|
21 |
|
|
|
22 |
if (! $renderFrame) return $this;
|
|
|
23 |
|
|
|
24 |
$resolvedViewFrame = new StackFrame(
|
|
|
25 |
[ 'file' => $renderFrame->object->getPath(), 'line' => $viewFrame->line ],
|
|
|
26 |
$this->basePath,
|
|
|
27 |
$this->vendorPath
|
|
|
28 |
);
|
|
|
29 |
|
|
|
30 |
return $this->copy(array_merge(
|
|
|
31 |
array_slice($this->frames, 0, array_search($viewFrame, $this->frames)),
|
|
|
32 |
[ $resolvedViewFrame ],
|
|
|
33 |
array_slice($this->frames, array_search($viewFrame, $this->frames) + 2)
|
|
|
34 |
));
|
|
|
35 |
}
|
|
|
36 |
}
|