|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Webino (http://webino.sk) |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/webino/WebinoDraw for the canonical source repository |
|
6
|
|
|
* @copyright Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk) |
|
7
|
|
|
* @author Peter Bačinský <[email protected]> |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace WebinoDraw\Instructions; |
|
12
|
|
|
|
|
13
|
|
|
use DOMNodeList; |
|
14
|
|
|
use WebinoDraw\Dom\Locator; |
|
15
|
|
|
use WebinoDraw\Exception\LogicException; |
|
16
|
|
|
use WebinoDraw\Service\DrawProfiler; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class ProfilingInstructionsRenderer |
|
20
|
|
|
*/ |
|
21
|
|
|
class ProfilingInstructionsRenderer extends InstructionsRenderer |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* @var DrawProfiler |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $profiler; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @return DrawProfiler |
|
30
|
|
|
*/ |
|
31
|
|
|
protected function getProfiler() |
|
32
|
|
|
{ |
|
33
|
|
|
if (null === $this->profiler) { |
|
34
|
|
|
throw new LogicException('Expected profiler'); |
|
35
|
|
|
} |
|
36
|
|
|
return $this->profiler; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @param object|DrawProfiler $profiler |
|
41
|
|
|
* @return self |
|
42
|
|
|
*/ |
|
43
|
|
|
public function setProfiler(DrawProfiler $profiler) |
|
44
|
|
|
{ |
|
45
|
|
|
$this->profiler = $profiler; |
|
46
|
|
|
return $this; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* {@inheritdoc} |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function createNodeSpec(array $specs) |
|
53
|
|
|
{ |
|
54
|
|
|
$spec = parent::createNodeSpec($specs); |
|
55
|
|
|
$spec['_key'] = key($specs); |
|
56
|
|
|
return $spec; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* {@inheritdoc} |
|
61
|
|
|
*/ |
|
62
|
|
|
protected function resolveIsNodeDisabled($node, array $spec) |
|
63
|
|
|
{ |
|
64
|
|
|
$isDisabled = parent::resolveIsNodeDisabled($node, $spec); |
|
65
|
|
|
$this->getProfiler()->beginNodeRender($spec, $isDisabled); |
|
66
|
|
|
return $isDisabled; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* {@inheritdoc} |
|
71
|
|
|
*/ |
|
72
|
|
|
protected function resolveIsEmptyNodes(DOMNodeList $nodes = null) |
|
73
|
|
|
{ |
|
74
|
|
|
// TODO profiler |
|
75
|
|
|
return parent::resolveIsEmptyNodes($nodes); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* {@inheritdoc} |
|
80
|
|
|
*/ |
|
81
|
|
|
protected function drawNodes(DOMNodeList $nodes, $helper, array $spec, array $vars) |
|
82
|
|
|
{ |
|
83
|
|
|
$profiler = $this->getProfiler(); |
|
84
|
|
|
$profiler->beginNodesDraw($nodes, $helper, $spec, $vars); |
|
85
|
|
|
parent::drawNodes($nodes, $helper, $spec, $vars); |
|
86
|
|
|
$profiler->finishNodesDraw($nodes, $helper, $spec, $vars); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|