39 lines
821 B
PHP
39 lines
821 B
PHP
<?php
|
|
|
|
namespace Trinity\Bundle\DashBoardBundle\Twig\Extension;
|
|
|
|
use Trinity\Bundle\DashBoardBundle\Zone\Zone;
|
|
|
|
class ZoneExtension extends \Twig_Extension
|
|
{
|
|
private $environment;
|
|
|
|
public function getName()
|
|
{
|
|
return 'zone_extension';
|
|
}
|
|
|
|
public function initRuntime(\Twig_Environment $environment)
|
|
{
|
|
$this->environment = $environment;
|
|
}
|
|
|
|
public function getFunctions()
|
|
{
|
|
return array(
|
|
'zoneRender' => new \Twig_Function_Method($this, 'zoneRender', array('is_safe' => array('html'))),
|
|
);
|
|
}
|
|
|
|
public function zoneRender(Zone $zone)
|
|
{
|
|
return $this->environment
|
|
->loadTemplate($zone->getTemplate())
|
|
->render(
|
|
array(
|
|
'zone' => $zone
|
|
)
|
|
);
|
|
}
|
|
}
|