Skip to content
Snippets Groups Projects
Commit 5cba5694 authored by Kevin Hill's avatar Kevin Hill
Browse files

adding renderAll twig function

parent a18bd2fa
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -38,24 +38,28 @@ class LavachartsExtension extends \Twig_Extension
*/
public function getFunctions()
{
$renderables = array_merge(['dashboard'], ChartFactory::$CHART_TYPES);
$renderableTypes = array_merge(['dashboard'], ChartFactory::$CHART_TYPES);
 
$renderFunctions = [];
 
foreach ($renderables as $renderable) {
$renderFunctions[] = new \Twig_SimpleFunction(strtolower($renderable),
function($label) use ($renderable) {
foreach ($renderableTypes as $type) {
$renderFunctions[] = new \Twig_SimpleFunction(strtolower($type),
function($label) use ($type) {
try {
$elementId = func_get_arg(1);
 
return $this->lava->render($renderable, $label, $elementId);
return $this->lava->render($type, $label, $elementId);
} catch (\Exception $e) {
return $this->lava->render($renderable, $label);
return $this->lava->render($type, $label);
}
}
);
}
 
$renderFunctions[] = new \Twig_SimpleFunction('renderAll', function() {
return $this->lava->renderAll();
});
return $renderFunctions;
}
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment