Version 1
[yaffs-website] / vendor / drupal / console / src / Command / Shared / ThemeRegionTrait.php
1 <?php
2
3 /**
4  * @file
5  * Contains Drupal\Console\Command\Shared\ThemeRegionTrait.
6  */
7
8 namespace Drupal\Console\Command\Shared;
9
10 use Drupal\Console\Core\Style\DrupalStyle;
11
12 trait ThemeRegionTrait
13 {
14     /**
15    * @param DrupalStyle $io
16    *
17    * @return mixed
18    */
19     public function regionQuestion(DrupalStyle $io)
20     {
21         $validators = $this->validator;
22         $regions = [];
23         while (true) {
24             $regionName = $io->ask(
25                 $this->trans('commands.generate.theme.questions.region-name'),
26                 'Content'
27             );
28
29             $regionMachineName = $this->stringConverter->createMachineName($regionName);
30             $regionMachineName = $io->ask(
31                 $this->trans('commands.generate.theme.questions.region-machine-name'),
32                 $regionMachineName,
33                 function ($regionMachineName) use ($validators) {
34                     return $validators->validateMachineName($regionMachineName);
35                 }
36             );
37
38             array_push(
39                 $regions,
40                 [
41                     'region_name' => $regionName,
42                     'region_machine_name' => $regionMachineName,
43                 ]
44             );
45
46             if (!$io->confirm(
47                 $this->trans('commands.generate.theme.questions.region-add'),
48                 true
49             )
50             ) {
51                 break;
52             }
53         }
54
55         return $regions;
56     }
57 }