Version 1
[yaffs-website] / vendor / drupal / console / src / Command / Shared / ThemeRegionTrait.php
diff --git a/vendor/drupal/console/src/Command/Shared/ThemeRegionTrait.php b/vendor/drupal/console/src/Command/Shared/ThemeRegionTrait.php
new file mode 100644 (file)
index 0000000..cf0e248
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\Console\Command\Shared\ThemeRegionTrait.
+ */
+
+namespace Drupal\Console\Command\Shared;
+
+use Drupal\Console\Core\Style\DrupalStyle;
+
+trait ThemeRegionTrait
+{
+    /**
+   * @param DrupalStyle $io
+   *
+   * @return mixed
+   */
+    public function regionQuestion(DrupalStyle $io)
+    {
+        $validators = $this->validator;
+        $regions = [];
+        while (true) {
+            $regionName = $io->ask(
+                $this->trans('commands.generate.theme.questions.region-name'),
+                'Content'
+            );
+
+            $regionMachineName = $this->stringConverter->createMachineName($regionName);
+            $regionMachineName = $io->ask(
+                $this->trans('commands.generate.theme.questions.region-machine-name'),
+                $regionMachineName,
+                function ($regionMachineName) use ($validators) {
+                    return $validators->validateMachineName($regionMachineName);
+                }
+            );
+
+            array_push(
+                $regions,
+                [
+                    'region_name' => $regionName,
+                    'region_machine_name' => $regionMachineName,
+                ]
+            );
+
+            if (!$io->confirm(
+                $this->trans('commands.generate.theme.questions.region-add'),
+                true
+            )
+            ) {
+                break;
+            }
+        }
+
+        return $regions;
+    }
+}