Skip to content

Commit

Permalink
Sanitized column with default value.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumit Madan committed Apr 14, 2020
1 parent 062e32c commit 35a3828
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .janitor.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ sanitize_tables:
# List of tables and their columns you want sanitized.
user:
- mail
sanitize_tables_default:
# List of tables and their columns you want sanitize with default value.
node:
uid: 1
trim_tables:
# List of tables to be trimmed (every 4th row kept)
- trim1
Expand Down
12 changes: 12 additions & 0 deletions src/DatabaseJanitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ public function sanitize($table_name, $col_name, $col_value, array $options) {
}
}

if (isset($options['sanitize_tables_default'])) {
foreach ($options['sanitize_tables_default'] as $table => $val) {
if ($table == $table_name) {
foreach ($options['sanitize_tables_default'][$table] as $col => $val) {
if ($col == $col_name) {
return $val;
}
}
}
}
}

return $col_value;
}

Expand Down

0 comments on commit 35a3828

Please sign in to comment.