Version 1
[yaffs-website] / vendor / drupal / console / src / Command / Shared / ConfirmationTrait.php
diff --git a/vendor/drupal/console/src/Command/Shared/ConfirmationTrait.php b/vendor/drupal/console/src/Command/Shared/ConfirmationTrait.php
new file mode 100644 (file)
index 0000000..aaf1800
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * @file
+ * Contains Drupal\Console\Command\Shared\ConfirmationTrait.
+ */
+
+namespace Drupal\Console\Command\Shared;
+
+use Drupal\Console\Core\Style\DrupalStyle;
+
+/**
+ * Class ConfirmationTrait
+ *
+ * @package Drupal\Console\Command
+ */
+trait ConfirmationTrait
+{
+    /**
+     * @param DrupalStyle $io
+     * @param bool        $yes
+     *
+     * @return bool
+     */
+    public function confirmGeneration(DrupalStyle $io, $yes = false)
+    {
+        if ($yes) {
+            return $yes;
+        }
+
+        $confirmation = $io->confirm(
+            $this->trans('commands.common.questions.confirm'),
+            true
+        );
+
+        if (!$confirmation) {
+            $io->warning($this->trans('commands.common.messages.canceled'));
+        }
+
+        return $confirmation;
+    }
+}