protected function execute(InputInterface $input, OutputInterface $output) { $componentName = $input->getOption('component'); if (!$componentName) { $output->writeln('<error>Component name must be given</error>'); $output->writeln('<comment>Use -c option to specify component name</comment>'); return 1; // set error status code } $component = new BitrixComponent($componentName); if (!$component->exists()) { $output->writeln("<error>Component {$componentName} not found </error>"); return 1; } $templateName = $input->getArgument('template'); if (!$templateName) { $templateName = ''; } $buff = new BufferedOutput(); $buff->writeln(sprintf('<?$APPLICATION->IncludeComponent("%s", "%s", array(', $component->getFullName(), $templateName)); $parameters = $component->getParameters()['PARAMETERS']; if ($input->getOption('sort')) { ksort($parameters); } foreach ($parameters as $name => $settings) { // TODO: Добавить вывод комментария с именем параметра. $defaultValue = $settings['DEFAULT'] ? $settings['DEFAULT'] : ''; $buff->writeln(sprintf(' "%s" => %s,', $name, var_export($defaultValue, true))); } $buff->writeln(' ),'); $buff->writeln(' false'); $buff->writeln(');/*' . $componentName . "*/?>"); $code = $buff->fetch(); if ($input->getOption('xclip')) { $clip = new ClipboardStream(); $clip->write($code); $output->writeln('<comment>Generated code was copied to clipboard</comment>'); } else { $output->write("<info>{$code}</info>"); } }