From d527a4bc9dd301f8fc2594891d1f1c2dbe721aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Melan=C3=A7on?= Date: Sun, 17 Jul 2016 12:26:09 -0400 Subject: [PATCH 1/2] Prevent fatal error on sites without dblog enabled --- src/Form/SendgridAdminSettingsForm.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Form/SendgridAdminSettingsForm.php b/src/Form/SendgridAdminSettingsForm.php index 70160c8..390249a 100644 --- a/src/Form/SendgridAdminSettingsForm.php +++ b/src/Form/SendgridAdminSettingsForm.php @@ -201,13 +201,20 @@ public function buildForm(array $form, FormStateInterface $form_state) { // '#description' => t('Whether or not to strip the query string from URLs when aggregating tracked URL data.'), // '#default_value' => $config->get('sendgrid_url_strip_qs'), // ); + if (\Drupal::moduleHandler()->moduleExists('dblog')) { + $log_url = Url::fromRoute('dblog.overview'); + } elseif (\Drupal::moduleHandler()->moduleExists('syslog') && \Drupal::moduleHandler()->moduleExists('help')) { + $log_url = new Url('help.page', ['name' => 'syslog']); + } else { + $log_url = 'https://drupal.org/page-that-needs-to-exist-on-simply-enabling-dblog-syslog-or-other-compatible-logger'; + } $form['send_options']['sendgrid_log_defaulted_sends'] = array( '#title' => t('Log sends from module/key pairs that are not registered independently in mailsystem.'), '#type' => 'checkbox', '#description' => t('If you select Sendgrid as the site-wide default email sender in %mailsystem and check this box, any messages that are sent through Sendgrid using module/key pairs that are not specifically registered in mailsystem will cause a message to be written to the %systemlog (type: Sendgrid, severity: info). Enable this to identify keys and modules for automated emails for which you would like to have more granular control. It is not recommended to leave this box checked for extended periods, as it slows Sendgrid and can clog your logs.', array( '%mailsystem' => $this->l(t('Mail System'), $mailSystemPath), - '%systemlog' => $this->l(t('system log'), Url::fromRoute('dblog.overview')), + '%systemlog' => $this->l(t('system log'), $log_url), )), '#default_value' => $config->get('sendgrid_log_defaulted_sends'), ); From 2994c819050f071b4ed4906c18c40bb1954d7c87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Melan=C3=A7on?= Date: Wed, 14 Dec 2016 18:41:00 -0500 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7414d5b..9dec8b6 100644 --- a/README.md +++ b/README.md @@ -25,5 +25,5 @@ Composer Manager (https://drupal.org/project/composer_manager) You could install and enable SendGrid PHP Library with Composer Manager. If not, module will try to find sendgrid/vendor/autoload.php file and SendGrid class. -Then enable module as usual and enter SendGrid API key in module settings. And enable module to be used in Mail System settings. +Then enable module as usual and enter your SendGrid API key in the module settings. Also configure your site's Mail System settings to use Sendgrid.