|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JumpGate\ViewResolution\Collectors; |
|
4
|
|
|
|
|
5
|
|
|
use DebugBar\Bridge\Twig\TwigCollector; |
|
6
|
|
|
use DebugBar\DataCollector\Renderable; |
|
7
|
|
|
use JumpGate\ViewResolution\Models\View as ViewModel; |
|
8
|
|
|
|
|
9
|
|
|
class AutoViewCollector extends TwigCollector implements Renderable |
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @var null|\JumpGate\ViewResolution\Models\View |
|
13
|
|
|
*/ |
|
14
|
|
|
public $viewModel = null; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Create a ViewCollector |
|
18
|
|
|
*/ |
|
19
|
|
|
public function __construct() |
|
20
|
|
|
{ |
|
21
|
|
|
$this->name = 'auto_views'; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function getName() |
|
25
|
|
|
{ |
|
26
|
|
|
return 'auto_views'; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function getWidgets() |
|
30
|
|
|
{ |
|
31
|
|
|
return [ |
|
32
|
|
|
'auto_resolved_view' => [ |
|
33
|
|
|
'icon' => 'archive', |
|
34
|
|
|
'widget' => 'PhpDebugBar.Widgets.VariableListWidget', |
|
35
|
|
|
'map' => 'auto_views', |
|
36
|
|
|
'default' => '{}', |
|
37
|
|
|
], |
|
38
|
|
|
]; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function addDetails(ViewModel $viewModel) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->viewModel = $viewModel; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function collect() |
|
47
|
|
|
{ |
|
48
|
|
|
$attemptedViews = $this->viewModel->attemptedViews; |
|
49
|
|
|
$prefixes = $this->viewModel->prefixes; |
|
50
|
|
|
|
|
51
|
|
|
$data = [ |
|
52
|
|
|
'resolved view' => $this->viewModel->view, |
|
53
|
|
|
'resolution type' => $this->viewModel->type, |
|
54
|
|
|
'attempted views' => $this->getDataFormatter() |
|
55
|
|
|
->formatVar($attemptedViews ? $attemptedViews->toArray() : $attemptedViews), |
|
56
|
|
|
'controller' => $this->viewModel->controller, |
|
57
|
|
|
'action' => is_null($this->viewModel->action) ? 'null (__invoke)' : $this->viewModel->action, |
|
58
|
|
|
'final prefix' => $this->viewModel->prefix, |
|
59
|
|
|
'possible prefixes' => $this->getDataFormatter() |
|
60
|
|
|
->formatVar($prefixes ? $prefixes->toArray() : $prefixes), |
|
61
|
|
|
'config index' => $this->viewModel->configIndex, |
|
62
|
|
|
]; |
|
63
|
|
|
|
|
64
|
|
|
return $data; |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|