Skip to content
Snippets Groups Projects
Commit 5787d897 authored by hamza dwaya's avatar hamza dwaya Committed by Hamza Daw
Browse files

Issue #3359737 by hamzadwaya: Setup module

parent dd2ac421
No related branches found
No related tags found
No related merge requests found
......@@ -2,23 +2,27 @@
namespace Drupal\unified_mail_dispatcher;
use Drupal\Core\Mail\MailManager as CoreMailManager;
use Drupal\Core\Mail\MailManager;
class UnifiedMailManager extends CoreMailManager {
/**
* Class UnifiedMailManager.
*/
class UnifiedMailManager extends MailManager {
public function mail($module, $key, $to, $langcode, $params = [], $reply = NULL, $send = TRUE) {
$config = \Drupal::config('unified_mail_dispatcher.settings');
$alter = $config->get('mail_alter');
if ($alter) {
$option = $config->get('alter_option');
if ($option == 'discord') {
$option = $config->get('alter_option');
// Load the discord service
$discord_manager = \Drupal::service('unified_mail_dispatcher.discord_manager');
$webhook_url = $config->get('webhook_url');
// Construct your message
$message = [
'content' => "Module: $module\nKey: $key\nRecipient: $to\nLanguage: $langcode\nParams: " . print_r($params, TRUE),
'content' => "Module: $module\nKey: $key\nRecipient: $to\nLanguage: $langcode\nParams: ",
];
$discord_manager->send($webhook_url, $message);
......
......@@ -3,4 +3,4 @@ description: Alters the Drupal mail system to send notifications to Discord or a
package: Custom
type: module
version: 1.0
core: 8.x
core_version_requirement: ^9.3 || ^10
services:
plugin.manager.mail:
class: Drupal\unified_mail_dispatcher\UnifiedMailManager
arguments: ['@container.namespaces', '@cache.discovery', '@module_handler']
parent: default_plugin_manager
arguments: ['@container.namespaces', '@cache.discovery', '@module_handler', '@config.factory', '@logger.factory', '@string_translation', '@renderer']
unified_mail_dispatcher.discord_manager:
class: Drupal\unified_mail_dispatcher\DiscordManager
arguments: ['@http_client', '@logger.factory']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment