comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:c75dbcec494b
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 }