Skip to content

Commit

Permalink
Allow gdpr expressions to also be passed as file
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-vanpraet committed Apr 24, 2024
1 parent 15b9324 commit 224c832
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Command/DumpCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 224c832

Please sign in to comment.