From a13868ac02471b75cdac8fb1d9bc82eb5889ad3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Le=20Ray?= Date: Fri, 25 Jan 2019 18:40:50 +0100 Subject: [PATCH] Add --gdpr-expressions-file option --- src/Command/DumpCommand.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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);