12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace TemplateBundle\Twig;
- use TemplateBundle\Services\TemplateService;
- class TemplateExtension extends \Twig_Extension
- {
- /**
- * @var TemplateService
- */
- private $templateService;
- /**
- * @param TemplateService $templateService
- */
- public function __construct(TemplateService $templateService)
- {
- $this->templateService = $templateService;
- }
- /**
- * @return array
- */
- public function getFunctions()
- {
- return array(
- new \Twig_SimpleFunction('template_exists', array($this, 'templateExists')),
- );
- }
- /**
- * @param string $name
- *
- * @return boolean
- */
- public function templateExists($name)
- {
- return $this->templateService->exists($name);
- }
- /**
- * @return string
- */
- public function getName()
- {
- return 'template_extension';
- }
- }
|