Skip to content

Commit

Permalink
Merge pull request #128 from City-of-Helsinki/UHF-8945_disable_email
Browse files Browse the repository at this point in the history
UHF-8945: disable email sending.
  • Loading branch information
rpnykanen authored Sep 8, 2023
2 parents 57c03f8 + d142c9e commit 10f5700
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions helfi_api_base.module
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,18 @@ function helfi_api_base_theme_suggestions_debug_item(array $variables) : array {
$suggestions[] = 'debug_item__' . strtr($variables['id'], '.', '_');
return $suggestions;
}

/**
* Implements hook_mail_alter().
*/
function helfi_api_base_mail_alter(&$message) : void {
// Prevent sending email if current site/environment is known to the resolver.
// Only helfi-drupal sites are affected by this change.
try {
\Drupal::service('helfi_api_base.environment_resolver')
->getActiveEnvironment();
$message['send'] = FALSE;
}
catch (\InvalidArgumentException) {
}
}

0 comments on commit 10f5700

Please sign in to comment.