a9256998b1a1c93bc1d763eae097cfdadfa5b6cb
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Helper / Renderer.php
1 <?php
2
3 namespace DrupalCodeGenerator\Helper;
4
5 use Symfony\Component\Console\Helper\Helper;
6 use Twig_Environment;
7
8 /**
9  * Output dumper form generators.
10  */
11 class Renderer extends Helper {
12
13   /**
14    * The twig environment.
15    *
16    * @var \Twig_Environment
17    */
18   protected $twig;
19
20   /**
21    * Constructs a generator command.
22    *
23    * @param \Twig_Environment $twig
24    *   The twig environment.
25    */
26   public function __construct(Twig_Environment $twig) {
27     $this->twig = $twig;
28   }
29
30   /**
31    * {@inheritdoc}
32    */
33   public function getName() {
34     return 'dcg_renderer';
35   }
36
37   /**
38    * Renders a template.
39    *
40    * @param string $template
41    *   Twig template.
42    * @param array $vars
43    *   Template variables.
44    *
45    * @return string
46    *   A string representing the rendered output.
47    */
48   public function render($template, array $vars) {
49     return $this->twig->render($template, $vars);
50   }
51
52   /**
53    * Adds a path where templates are stored.
54    *
55    * @param string $path
56    *   A path where to look for templates.
57    */
58   public function addPath($path) {
59     return $this->twig->getLoader()->addPath($path);
60   }
61
62 }