From 936d6f8497edd9b57dc5b604d9d5c3202d9405aa Mon Sep 17 00:00:00 2001 From: Blaize Kaye Date: Sun, 24 Jun 2018 18:00:35 +1200 Subject: [PATCH] Adds basic no data settings from command line and options --- src/Command/DumpCommand.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Command/DumpCommand.php b/src/Command/DumpCommand.php index 8768f2c..0f25b74 100644 --- a/src/Command/DumpCommand.php +++ b/src/Command/DumpCommand.php @@ -135,6 +135,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $dumpSettings['exclude-tables'] = $this->getExcludedTables($dumpSettings); + $dumpSettings = $this->determineNoDataSettings($input, $dumpSettings); + if (!empty($dumpSettings['gdpr-expressions'])) { $dumpSettings['gdpr-expressions'] = json_decode($dumpSettings['gdpr-expressions'], true); @@ -306,4 +308,26 @@ protected function displayEffectiveReplacements( $output->writeln("gdpr-replacements=" . json_encode($dumpSettings['gdpr-replacements'])); } } + + /** + * @param \Symfony\Component\Console\Input\InputInterface $input + * @param $dumpSettings + * + * @return mixed + */ + protected function determineNoDataSettings( + InputInterface $input, + $dumpSettings + ) { + if ($input->getOption('no-data')) { + $dumpSettings['no-data'] = true; + } elseif (!empty($dumpSettings['gdpr-skip-tables'])) { + $dumpSettings['no-data'] = json_decode($dumpSettings['gdpr-skip-tables']); + if (json_last_error()) { + throw new \UnexpectedValueException(sprintf('Invalid gdpr-skip-tables json (%s): %s', + json_last_error_msg(), $dumpSettings['gdpr-expressions'])); + } + } + return $dumpSettings; + } }