From 224c832b71d96b627615789d8030246ae8cd9eec Mon Sep 17 00:00:00 2001 From: Nick Vanpraet Date: Thu, 11 Apr 2024 17:33:40 +0200 Subject: [PATCH] Allow gdpr expressions to also be passed as file --- src/Command/DumpCommand.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Command/DumpCommand.php b/src/Command/DumpCommand.php index 15809d1..317be78 100644 --- a/src/Command/DumpCommand.php +++ b/src/Command/DumpCommand.php @@ -109,6 +109,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, @@ -192,6 +194,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);