. */ /* */ /*************************************************************************************/ namespace DebugBar\Smarty\Plugin; use Thelia\Core\Template\Smarty\AbstractSmartyPlugin; use Thelia\Core\Template\Smarty\an; use Thelia\Core\Template\Smarty\SmartyPluginDescriptor; use DebugBar\DebugBar as BaseDebugBar; /** * Class DebugBar * @author Manuel Raynaud */ class DebugBar extends AbstractSmartyPlugin { protected $debugBar; protected $debugMode; public function __construct(BaseDebugBar $debugbar, $debugMode) { $this->debugBar = $debugbar; $this->debugMode = $debugMode; } public function render($params, \Smarty_Internal_Template $template) { $render = ""; if ($this->debugMode) { $render = $this->debugBar->getJavascriptRenderer()->render(); } return $render; } public function renderHead($params, \Smarty_Internal_Template $template) { $render = ""; if ($this->debugMode) { $javascriptRenderer = $this->debugBar->getJavascriptRenderer(); $assets = $javascriptRenderer->getAsseticCollection(); $cssCollection = $assets[0]; $jsCollection = $assets[1]; $render .= sprintf('', $cssCollection->dump()); $render .= sprintf('', $jsCollection->dump()); } return $render; } /** * @return an array of SmartyPluginDescriptor */ public function getPluginDescriptors() { return array( new SmartyPluginDescriptor("function", "debugbar_renderHead", $this, "renderHead"), new SmartyPluginDescriptor("function", "debugbar_render", $this, "render") ); } }