forked from barryvdh/laravel-debugbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDebugbarViewEngine.php
55 lines (46 loc) · 1.19 KB
/
DebugbarViewEngine.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
declare(strict_types=1);
namespace Barryvdh\Debugbar;
use Illuminate\Contracts\View\Engine;
class DebugbarViewEngine implements Engine
{
/**
* @var Engine
*/
protected $engine;
/**
* @var LaravelDebugbar
*/
protected $laravelDebugbar;
/**
* @param Engine $engine
* @param LaravelDebugbar $laravelDebugbar
*/
public function __construct(Engine $engine, LaravelDebugbar $laravelDebugbar)
{
$this->engine = $engine;
$this->laravelDebugbar = $laravelDebugbar;
}
/**
* @param string $path
* @param array $data
* @return string
*/
public function get($path, array $data = [])
{
$shortPath = ltrim(str_replace(base_path(), '', realpath($path)), '/');
return $this->laravelDebugbar->measure($shortPath, function () use ($path, $data) {
return $this->engine->get($path, $data);
});
}
/**
* NOTE: This is done to support other Engine swap (example: Livewire).
* @param $name
* @param $arguments
* @return mixed
*/
public function __call($name, $arguments)
{
return $this->engine->$name(...$arguments);
}
}