/** * Execute the command * * @param InputInterface $input * @param OutputInterface $output * * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { $db = $input->getOption('db'); if (empty($db)) { throw new \InvalidArgumentException('You must define the database name with --db'); } $password = $input->getOption('password'); if (is_null($password)) { $helper = $this->getHelper('question'); $question = new Question('Password: '******'host'), $input->getOption('user'), $password); } catch (\Exception $e) { throw new \RuntimeException("Can't connect to the database. Check your credentials"); } $writer = new \Inet\Neuralyzer\Configuration\Writer(); $ignoreFields = $input->getOption('ignore-field'); $writer->protectCols($input->getOption('protect')); // Override the protection if fields are defined if (!empty($ignoreFields)) { $writer->protectCols(true); $writer->setProtectedCols($ignoreFields); } $writer->setIgnoredTables($input->getOption('ignore-table')); $data = $writer->generateConfFromDB($pdo, new \Inet\Neuralyzer\Guesser()); $writer->save($data, $input->getOption('file')); $output->writeln('<comment>Configuration written to ' . $input->getOption('file') . '</comment>'); }
protected function execute(InputInterface $input, OutputInterface $output) { $pdo = $this->getService('sugarcrm.pdo'); // Get the list of fields in SugaCRM for each module, with the table name as key $dropdowns = $this->getModulesDropdowns(); $guesser = new \SugarCli\Utils\AnonymizeGuesser(); $guesser->setExtraColsNameMapping($dropdowns); $writer = new \Inet\Neuralyzer\Configuration\Writer(); // Merge all the ways to get the tables to ignore $writer->setIgnoredTables(array_merge($this->ignoredTables, $this->getRelsTables($pdo), $input->getOption('ignore-table'))); // Define the fields to ignore $writer->protectCols(true); $writer->setProtectedCols(array_merge($this->ignoreFields, $input->getOption('ignore-field'))); $data = $writer->generateConfFromDB($pdo, $guesser); // go to my current folder $writer->save($data, $input->getOption('file')); $output->writeln('<comment>Configuration written to ' . $input->getOption('file') . '</comment>'); // DANS LE RUN NE PAS OUBLIER DE VIDER LES _AUDIT }