Yaffs site version 1.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
58       /**
59    * @param DrupalStyle $io
60    *
61    * @return mixed
62    */
63     public function libraryQuestion(DrupalStyle $io)
64     {
65         $validators = $this->validator;
66         $libraries = [];
67         while (true) {
68             $libraryName = $io->ask(
69                 $this->trans('commands.generate.theme.questions.library-name')
70             );
71             
72             $libraryVersion = $io->ask(
73                 $this->trans('commands.generate.theme.questions.library-version'),
74                 '1.0'
75             );
76             
77             array_push(
78                 $libraries,
79                 [
80                     'library_name' => $libraryName,
81                     'library_version'=> $libraryVersion,
82                 ]
83             );
84
85             if (!$io->confirm(
86                 $this->trans('commands.generate.theme.questions.library-add'),
87                 true
88             )
89             ) {
90                 break;
91             }
92         }
93
94         return $libraries;
95     }
96 }