Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2f67776

Browse filesBrowse files
committed
removed unneeded safeguard as it's already done during compilation
1 parent bbad387 commit 2f67776
Copy full SHA for 2f67776

File tree

Expand file treeCollapse file tree

2 files changed

+8
-19
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+8
-19
lines changed

‎src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/StopwatchExtension.php
+5-14Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public function __construct(Stopwatch $stopwatch = null)
2828
$this->stopwatch = $stopwatch;
2929
}
3030

31+
public function getStopwatch()
32+
{
33+
return $this->stopwatch;
34+
}
35+
3136
public function getTokenParsers()
3237
{
3338
return array(
@@ -44,18 +49,4 @@ public function getName()
4449
{
4550
return 'stopwatch';
4651
}
47-
48-
public function startEvent($name)
49-
{
50-
if ($this->stopwatch instanceof Stopwatch) {
51-
$this->stopwatch->start($name, 'template');
52-
}
53-
}
54-
55-
public function stopEvent($name)
56-
{
57-
if ($this->stopwatch instanceof Stopwatch) {
58-
$this->stopwatch->stop($name);
59-
}
60-
}
6152
}

‎src/Symfony/Bridge/Twig/Node/StopwatchNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Node/StopwatchNode.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ public function __construct($name, $body, $lineno = 0, $tag = null)
2525

2626
public function compile(\Twig_Compiler $compiler)
2727
{
28-
$name = $this->getAttribute('name');
29-
3028
$compiler
31-
->write('$this->env->getExtension(\'stopwatch\')->startEvent(\''.$name.'\');')
29+
->write(sprintf("\$this->env->getExtension('stopwatch')->getStopwatch()->start('%s', 'template');\n", $this->getAttribute('name')))
3230
->subcompile($this->getNode('body'))
33-
->write('$this->env->getExtension(\'stopwatch\')->stopEvent(\''.$name.'\');')
34-
->raw("\n");
31+
->write(sprintf("\$this->env->getExtension('stopwatch')->getStopwatch()->stop('%s');\n", $this->getAttribute('name')))
32+
;
3533
}
3634
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.