Mercurial > hg > cmmr2012-drupal-site
diff vendor/chi-teck/drupal-code-generator/src/Helper/Renderer.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/chi-teck/drupal-code-generator/src/Helper/Renderer.php Thu Jul 05 14:24:15 2018 +0000 @@ -0,0 +1,62 @@ +<?php + +namespace DrupalCodeGenerator\Helper; + +use Symfony\Component\Console\Helper\Helper; +use Twig_Environment; + +/** + * Output dumper form generators. + */ +class Renderer extends Helper { + + /** + * The twig environment. + * + * @var \Twig_Environment + */ + protected $twig; + + /** + * Constructs a generator command. + * + * @param \Twig_Environment $twig + * The twig environment. + */ + public function __construct(Twig_Environment $twig) { + $this->twig = $twig; + } + + /** + * {@inheritdoc} + */ + public function getName() { + return 'dcg_renderer'; + } + + /** + * Renders a template. + * + * @param string $template + * Twig template. + * @param array $vars + * Template variables. + * + * @return string + * A string representing the rendered output. + */ + public function render($template, array $vars) { + return $this->twig->render($template, $vars); + } + + /** + * Adds a path where templates are stored. + * + * @param string $path + * A path where to look for templates. + */ + public function addPath($path) { + return $this->twig->getLoader()->addPath($path); + } + +}