Skip to content

Commit 53c0ac2

Browse files
authored
No measure timeline views.exclude_paths directories (#1609)
1 parent 07a947e commit 53c0ac2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/DebugbarViewEngine.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ class DebugbarViewEngine implements Engine
1818
*/
1919
protected $laravelDebugbar;
2020

21+
/**
22+
* @var array
23+
*/
24+
protected $exclude_paths;
25+
2126
/**
2227
* @param Engine $engine
2328
* @param LaravelDebugbar $laravelDebugbar
@@ -26,6 +31,7 @@ public function __construct(Engine $engine, LaravelDebugbar $laravelDebugbar)
2631
{
2732
$this->engine = $engine;
2833
$this->laravelDebugbar = $laravelDebugbar;
34+
$this->exclude_paths = app('config')->get('debugbar.options.views.exclude_paths', []);
2935
}
3036

3137
/**
@@ -38,13 +44,19 @@ public function get($path, array $data = [])
3844
$basePath = base_path();
3945
$shortPath = @file_exists((string) $path) ? realpath($path) : $path;
4046

41-
if (strpos($shortPath, $basePath) === 0) {
47+
if (str_starts_with($shortPath, $basePath)) {
4248
$shortPath = ltrim(
4349
str_replace('\\', '/', substr($shortPath, strlen($basePath))),
4450
'/'
4551
);
4652
}
4753

54+
foreach ($this->exclude_paths as $excludePath) {
55+
if (str_starts_with($shortPath, $excludePath)) {
56+
return $this->engine->get($path, $data);
57+
}
58+
}
59+
4860
return $this->laravelDebugbar->measure($shortPath, function () use ($path, $data) {
4961
return $this->engine->get($path, $data);
5062
}, 'views');

0 commit comments

Comments
 (0)