-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtension.php
46 lines (40 loc) · 1.18 KB
/
Extension.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
<?php
namespace smtgr15\TwigDebugBar;
class Extension extends \Twig_Extension
{
public function __construct($assetPath = null)
{
$this->debugbar = new \DebugBar\StandardDebugBar();
$this->renderer = $this->debugbar->getJavascriptRenderer();
if (!is_null($assetPath)) {
$this->renderer->setBaseUrl($assetPath);
}
}
public function getDebugBar(){
return $this->debugbar;
}
public function getFunctions()
{
return array(
new \Twig_Function('dbg_message', [$this, 'message']),
new \Twig_Function('dbg_render', [$this, 'render', ['is_safe' => ['html']]]),
new \Twig_Function('dbg_renderHead', [$this, 'renderHead', ['is_safe' => ['html']]]),
);
}
public function message($text, $label = info)
{
$this->debugbar["messages"]->addMessage($text, $label);
}
public function render()
{
return $this->renderer->render();
}
public function renderHead()
{
return $this->renderer->renderHead();
}
public function getName()
{
return 'debugbar_extension';
}
}