Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TablesWhitelistGenerateCommand.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 use Symfony\Component\Console\Command\Command;
14 use Symfony\Component\Console\Input\InputInterface;
15 use Symfony\Component\Console\Input\InputOption;
16 use Symfony\Component\Console\Output\OutputInterface;
17 
23 class TablesWhitelistGenerateCommand extends Command
24 {
28  const MODULE_NAME_KEY = 'module-name';
29 
33  private $whitelistGenerator;
34 
39  public function __construct(
40  WhitelistGenerator $whitelistGenerator,
41  $name = null
42  ) {
43  $this->whitelistGenerator = $whitelistGenerator;
44  parent::__construct($name);
45  }
46 
52  protected function configure()
53  {
54  $this->setName('setup:db-declaration:generate-whitelist')
55  ->setDescription(
56  'Generate whitelist of tables and columns that are allowed to be edited by declaration installer'
57  )
58  ->setDefinition(
59  [
60  new InputOption(
61  self::MODULE_NAME_KEY,
62  null,
63  InputOption::VALUE_OPTIONAL,
64  'Name of the module where whitelist will be generated',
66  )
67  ]
68  );
69  parent::configure();
70  }
71 
75  protected function execute(InputInterface $input, OutputInterface $output) : int
76  {
77  $moduleName = $input->getOption(self::MODULE_NAME_KEY);
78 
79  try {
80  $this->whitelistGenerator->generate($moduleName);
81  } catch (ConfigurationMismatchException $e) {
82  $output->writeln($e->getMessage());
83  return \Magento\Framework\Console\Cli::RETURN_FAILURE;
84  } catch (\Exception $e) {
85  return \Magento\Framework\Console\Cli::RETURN_FAILURE;
86  }
87 
88  return \Magento\Framework\Console\Cli::RETURN_SUCCESS;
89  }
90 }
if(!isset($_GET['name'])) $name
Definition: log.php:14