10759e4eb44967298b0b66a40e115f85dff4d81f
[yaffs-website] / vendor / drupal / console / src / Command / Shared / ThemeBreakpointTrait.php
1 <?php
2
3 /**
4  * @file
5  * Contains Drupal\Console\Command\Shared\ThemeBreakpointTrait.
6  */
7
8 namespace Drupal\Console\Command\Shared;
9
10 use Drupal\Console\Core\Style\DrupalStyle;
11
12 trait ThemeBreakpointTrait
13 {
14     /**
15      * @param DrupalStyle $io
16      *
17      * @return mixed
18      */
19     public function breakpointQuestion(DrupalStyle $io)
20     {
21         $stringUtils = $this->stringConverter;
22         $validators = $this->validator;
23
24         $breakpoints = [];
25         while (true) {
26             $breakPointName = $io->ask(
27                 $this->trans('commands.generate.theme.questions.breakpoint-name'),
28                 'narrow',
29                 function ($breakPointName) use ($validators) {
30                     return $validators->validateMachineName($breakPointName);
31                 }
32             );
33
34             $breakPointLabel = $stringUtils->createMachineName($breakPointName);
35             $breakPointLabel = $io->ask(
36                 $this->trans('commands.generate.theme.questions.breakpoint-label'),
37                 $breakPointLabel,
38                 function ($breakPointLabel) use ($validators) {
39                     return $validators->validateMachineName($breakPointLabel);
40                 }
41             );
42
43             $breakPointMediaQuery = $io->ask(
44                 $this->trans('commands.generate.theme.questions.breakpoint-media-query'),
45                 'all and (min-width: 560px) and (max-width: 850px)'
46             );
47
48             $breakPointWeight = $io->ask(
49                 $this->trans('commands.generate.theme.questions.breakpoint-weight'),
50                 '1'
51             );
52
53             $breakPointMultipliers = $io->ask(
54                 $this->trans('commands.generate.theme.questions.breakpoint-multipliers'),
55                 '1x'
56             );
57
58             array_push(
59                 $breakpoints,
60                 [
61                     'breakpoint_name' => $breakPointName,
62                     'breakpoint_label' => $breakPointLabel,
63                     'breakpoint_media_query' => $breakPointMediaQuery,
64                     'breakpoint_weight' => $breakPointWeight,
65                     'breakpoint_multipliers' => $breakPointMultipliers
66                 ]
67             );
68
69             if (!$io->confirm(
70                 $this->trans('commands.generate.theme.questions.breakpoint-add'),
71                 true
72             )
73             ) {
74                 break;
75             }
76         }
77
78         return $breakpoints;
79     }
80 }