5 * Contains \Drupal\Console\Command\Generate\BreakPointCommand.
8 namespace Drupal\Console\Command\Generate;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Symfony\Component\Console\Command\Command;
14 use Drupal\Core\Extension\ThemeHandler;
15 use Drupal\Console\Command\Shared\ThemeRegionTrait;
16 use Drupal\Console\Command\Shared\ThemeBreakpointTrait;
17 use Drupal\Console\Command\Shared\ConfirmationTrait;
18 use Drupal\Console\Core\Command\Shared\CommandTrait;
19 use Drupal\Console\Core\Style\DrupalStyle;
20 use Drupal\Console\Utils\Validator;
21 use Drupal\Console\Core\Utils\StringConverter;
22 use Drupal\Console\Generator\BreakPointGenerator;
27 class BreakPointCommand extends Command
30 use ConfirmationTrait;
32 use ThemeBreakpointTrait;
35 * @var BreakPointGenerator
52 protected $themeHandler;
61 * @var StringConverter
63 protected $stringConverter;
66 * BreakPointCommand constructor.
68 * @param BreakPointGenerator $generator
70 * @param ThemeHandler $themeHandler
71 * @param Validator $validator
72 * @param StringConverter $stringConverter
74 public function __construct(
75 BreakPointGenerator $generator,
77 ThemeHandler $themeHandler,
79 StringConverter $stringConverter
81 $this->generator = $generator;
82 $this->appRoot = $appRoot;
83 $this->themeHandler = $themeHandler;
84 $this->validator = $validator;
85 $this->stringConverter = $stringConverter;
86 parent::__construct();
92 protected function configure()
95 ->setName('generate:breakpoint')
96 ->setDescription($this->trans('commands.generate.breakpoint.description'))
97 ->setHelp($this->trans('commands.generate.breakpoint.help'))
101 InputOption::VALUE_REQUIRED,
102 $this->trans('commands.generate.breakpoint.options.theme')
107 InputOption::VALUE_OPTIONAL,
108 $this->trans('commands.generate.breakpoint.options.breakpoints')
115 protected function execute(InputInterface $input, OutputInterface $output)
117 $io = new DrupalStyle($input, $output);
119 // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
120 if (!$this->confirmGeneration($io)) {
124 $validators = $this->validator;
125 // we must to ensure theme exist
126 $machine_name = $validators->validateMachineName($input->getOption('theme'));
127 $theme_path = $drupal_root . $input->getOption('theme');
128 $breakpoints = $input->getOption('breakpoints');
130 $this->generator->generate(
142 protected function interact(InputInterface $input, OutputInterface $output)
144 $io = new DrupalStyle($input, $output);
146 $drupalRoot = $this->appRoot;
148 // --base-theme option.
149 $base_theme = $input->getOption('theme');
152 $themeHandler = $this->themeHandler;
153 $themes = $themeHandler->rebuildThemeData();
154 $themes['classy'] ='';
156 uasort($themes, 'system_sort_modules_by_info_name');
158 $base_theme = $io->choiceNoList(
159 $this->trans('commands.generate.breakpoint.questions.theme'),
162 $input->setOption('theme', $base_theme);
165 // --breakpoints option.
166 $breakpoints = $input->getOption('breakpoints');
168 $breakpoints = $this->breakpointQuestion($io);
169 $input->setOption('breakpoints', $breakpoints);