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}
*/