Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console / src / Command / Shared / ConfirmationTrait.php
1 <?php
2
3 /**
4  * @file
5  * Contains Drupal\Console\Command\Shared\ConfirmationTrait.
6  */
7
8 namespace Drupal\Console\Command\Shared;
9
10 use Drupal\Console\Core\Style\DrupalStyle;
11
12 /**
13  * Class ConfirmationTrait
14  *
15  * @package Drupal\Console\Command
16  */
17 trait ConfirmationTrait
18 {
19     /**
20      * @param DrupalStyle $io
21      * @param bool        $yes
22      *
23      * @return bool
24      */
25     public function confirmGeneration(DrupalStyle $io, $yes = false)
26     {
27         if ($yes) {
28             return $yes;
29         }
30
31         $confirmation = $io->confirm(
32             $this->trans('commands.common.questions.confirm'),
33             true
34         );
35
36         if (!$confirmation) {
37             $io->warning($this->trans('commands.common.messages.canceled'));
38         }
39
40         return $confirmation;
41     }
42 }