protected function getFunctionByName(\Twig_Extension $extension, $name) { foreach ($extension->getFunctions() as $function) { if ($function->getName() == $name) { return $function; } } }
/** * Load all filters provided by the current extension into the TwigRenderizer * * @param TwigRenderizer $renderizer Twig renderizer */ public function load(TwigRenderizer $renderizer) { $filters = $this->extension->getFilters(); foreach ($filters as $filter) { $name = $filter->getName(); $callable = $filter->getCallable(); $options = array('needs_environment' => $filter->needsEnvironment()); $renderizer->addTwigFilter($name, $callable, $options); } }
/** * {@inheritdoc} */ public function initRuntime(Twig_Environment $environment) { /** @var $environment sfTwigEnvironment */ if ($environment instanceof sfTwigEnvironment) { $this->sfContext = $environment->getContext(); } else { throw new \InvalidArgumentException('$environment must be instance of sfTwigEnvironment class'); } parent::initRuntime($environment); }
public function initRuntime(\Twig_Environment $environment) { parent::initRuntime($environment); $this->directory = $this->app['request']->getBasePath(); if (isset($this->options['asset.directory'])) { $this->directory = $this->options['asset.directory']; } if (isset($this->options['asset.version'])) { $this->version = $this->options['asset.version']; } }
public function initRuntime(\Twig_Environment $environment) { $this->twig = $environment; parent::initRuntime($environment); }
public function getGlobals() { $globals = parent::getGlobals(); $globals['wordpress_loader'] = $this->wordpress_loader; return $globals; }
public function initRuntime(\Twig_Environment $environment) { parent::initRuntime($environment); $this->twig = $environment->loadTemplate($this->template); }
/** * Init runtime * * @access public */ public function initRuntime(\Twig_Environment $environment) { parent::initRuntime($environment); $this->environment = $environment; }
/** * @param \Twig_Extension $extension * * @return RenderEngineExtensionManager */ public function addExtension(\Twig_Extension $extension) { $this->extensions[$extension->getName()] = $extension; return $this; }
public function getFilters() { return array('sm_absolutize' => new \Twig_Filter_Method($this, 'getAbsoluteUrl'), 'sm_format_date' => new \Twig_Filter_Method($this, 'getFormattedDate')); return parent::getFilters(); }