Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / service / twig-extension.twig
index 39f9902114bfa0102fc7cbd95376acf8f71ad9ab..99f5acd9016ea2617ca3dd7506b37506e487936e 100644 (file)
@@ -2,18 +2,34 @@
 
 namespace Drupal\{{ machine_name }};
 
+{% if di %}
+use Drupal\example\ExampleInterface;
+
+{% endif %}
 /**
  * Twig extension.
  */
 class {{ class }} extends \Twig_Extension {
 
+{% if di %}
   /**
-   * {@inheritdoc}
+   * The example service.
+   *
+   * @var \Drupal\example\ExampleInterface
+   */
+  protected $example;
+
+  /**
+   * Constructs a new {{ class }} instance.
+   *
+   * @param \Drupal\example\ExampleInterface $example
+   *   The example service.
    */
-  public function getName() {
-    return '{{ machine_name }}';
+  public function __construct(ExampleInterface $example) {
+    $this->example = $example;
   }
 
+{% endif %}
   /**
    * {@inheritdoc}
    */