Version 1
[yaffs-website] / vendor / drupal / console / templates / module / src / Controller / controller.php.twig
diff --git a/vendor/drupal/console/templates/module/src/Controller/controller.php.twig b/vendor/drupal/console/templates/module/src/Controller/controller.php.twig
new file mode 100644 (file)
index 0000000..cf52f16
--- /dev/null
@@ -0,0 +1,71 @@
+{% extends "base/class.php.twig" %}
+
+{% block file_path %}
+\Drupal\{{module}}\Controller\{{ class_name }}.
+{% endblock %}
+
+{% block namespace_class %}
+namespace Drupal\{{module}}\Controller;
+{% endblock %}
+
+{% block use_class %}
+use Drupal\Core\Controller\ControllerBase;
+{% if services is not empty %}
+use Symfony\Component\DependencyInjection\ContainerInterface;
+{% endif %}
+{% endblock %}
+{% block class_declaration %}
+/**
+ * Class {{ class_name }}.
+ *
+ * @package Drupal\{{ module }}\Controller
+ */
+class {{ class_name }} extends ControllerBase {% endblock %}
+{% block class_construct %}
+{% if services is not empty %}
+
+  /**
+   * {@inheritdoc}
+   */
+  public function __construct({{ servicesAsParameters(services)|join(', ') }}) {
+{{ serviceClassInitialization(services) }}
+  }
+{% endif %}
+{% endblock %}
+{% block class_create %}
+{% if services is not empty %}
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container) {
+    return new static(
+{{ serviceClassInjection(services) }}
+    );
+  }
+
+{% endif %}
+{% endblock %}
+{% block class_methods %}
+{% for route in routes %}
+  /**
+   * {{ route.method | capitalize }}.
+   *
+   * @return string
+   *   Return Hello string.
+   */
+  public function {{route.method}}({{ argumentsFromRoute(route.path)|join(', ') }}) {
+{% if argumentsFromRoute(route.path) is not empty %}
+    return [
+      '#type' => 'markup',
+      '#markup' => $this->t('Implement method: {{route.method}} with parameter(s): {{ argumentsFromRoute(route.path)|join(', ') }}'),
+    ];
+{% else %}
+    return [
+      '#type' => 'markup',
+      '#markup' => $this->t('Implement method: {{route.method}}')
+    ];
+{% endif %}
+  }
+{% endfor %}
+{% endblock %}