X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FMail%2FMailManager.php;fp=web%2Fcore%2Flib%2FDrupal%2FCore%2FMail%2FMailManager.php;h=bbc0432c6da4df16c23f6f6a6127d81af1b38a06;hp=348dceeb208d967356001561062e201ff26cb243;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hpb=74df008bdbb3a11eeea356744f39b802369bda3c diff --git a/web/core/lib/Drupal/Core/Mail/MailManager.php b/web/core/lib/Drupal/Core/Mail/MailManager.php index 348dceeb2..bbc0432c6 100644 --- a/web/core/lib/Drupal/Core/Mail/MailManager.php +++ b/web/core/lib/Drupal/Core/Mail/MailManager.php @@ -2,13 +2,17 @@ namespace Drupal\Core\Mail; +use Drupal\Component\Render\MarkupInterface; use Drupal\Component\Render\PlainTextOutput; +use Drupal\Component\Utility\Html; use Drupal\Component\Utility\Unicode; use Drupal\Core\Logger\LoggerChannelFactoryInterface; +use Drupal\Core\Messenger\MessengerTrait; use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Config\ConfigFactoryInterface; +use Drupal\Core\Render\Markup; use Drupal\Core\Render\RenderContext; use Drupal\Core\Render\RendererInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -23,6 +27,7 @@ use Drupal\Core\StringTranslation\TranslationInterface; */ class MailManager extends DefaultPluginManager implements MailManagerInterface { + use MessengerTrait; use StringTranslationTrait; /** @@ -275,6 +280,13 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface { // Retrieve the responsible implementation for this message. $system = $this->getInstance(['module' => $module, 'key' => $key]); + // Attempt to convert relative URLs to absolute. + foreach ($message['body'] as &$body_part) { + if ($body_part instanceof MarkupInterface) { + $body_part = Markup::create(Html::transformRootRelativeUrlsToAbsolute((string) $body_part, \Drupal::request()->getSchemeAndHttpHost())); + } + } + // Format the message body. $message = $system->format($message); @@ -303,7 +315,7 @@ class MailManager extends DefaultPluginManager implements MailManagerInterface { '%to' => $message['to'], '%reply' => $message['reply-to'] ? $message['reply-to'] : $this->t('not set'), ]); - drupal_set_message($this->t('Unable to send email. Contact the site administrator if the problem persists.'), 'error'); + $this->messenger()->addError($this->t('Unable to send email. Contact the site administrator if the problem persists.')); } } }