Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Controller.php
index 65d301456c42c49fcd0067f5ce6d446890aea95d..814316b8b4dd134196a1711e2e58cd622ca4ff6b 100644 (file)
@@ -23,14 +23,21 @@ class Controller extends BaseGenerator {
    */
   protected function interact(InputInterface $input, OutputInterface $output) {
     $questions = Utils::defaultQuestions();
+
     $default_class = function ($vars) {
-      return Utils::camelize($vars['name'] . 'Controller');
+      return Utils::camelize($vars['name']) . 'Controller';
     };
     $questions['class'] = new Question('Class', $default_class);
-    $questions['route'] = new ConfirmationQuestion('Would you like to create a route for this controller?');
+
     $vars = $this->collectVars($input, $output, $questions);
 
-    if ($vars['route']) {
+    $di_question = new ConfirmationQuestion('Would you like to inject dependencies?', FALSE);
+    if ($this->ask($input, $output, $di_question)) {
+      $this->collectServices($input, $output);
+    }
+
+    $route_question = new ConfirmationQuestion('Would you like to create a route for this controller?');
+    if ($this->ask($input, $output, $route_question)) {
       $route_path = '/' . str_replace('_', '-', $vars['machine_name']) . '/example';
       $route_questions['route_name'] = new Question('Route name', '{machine_name}.example');
       $route_questions['route_path'] = new Question('Route path', $route_path);