diff --git a/src/Command/DumpCommand.php b/src/Command/DumpCommand.php index 712b0fb..32daa2c 100644 --- a/src/Command/DumpCommand.php +++ b/src/Command/DumpCommand.php @@ -103,6 +103,8 @@ protected function configure() 'Dump only rows selected by given WHERE condition.') ->addOption('gdpr-expressions', null, InputOption::VALUE_OPTIONAL, 'A json of gdpr sql-expressions keyed by table and column.') + ->addOption('gdpr-expressions-file', null, InputOption::VALUE_OPTIONAL, + 'File that contains a json of gdpr sql-expressions keyed by table and column.') ->addOption('gdpr-replacements', null, InputOption::VALUE_OPTIONAL, 'A json of gdpr replacement values keyed by table and column.') ->addOption('gdpr-replacements-file', null, InputOption::VALUE_OPTIONAL, @@ -202,6 +204,15 @@ protected function execute(InputInterface $input, OutputInterface $output) } } + if (!empty($dumpSettings['gdpr-expressions-file'])) { + $dumpSettings['gdpr-expressions'] = json_decode(file_get_contents($dumpSettings['gdpr-expressions-file']), + true); + if (json_last_error()) { + throw new \UnexpectedValueException(sprintf('Invalid gdpr-expressions json (%s): %s', + json_last_error_msg(), $dumpSettings['gdpr-expressions'])); + } + } + if (!empty($dumpSettings['gdpr-replacements'])) { $dumpSettings['gdpr-replacements'] = json_decode($dumpSettings['gdpr-replacements'], true);