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; + } }