Skip to content
Snippets Groups Projects
Commit 6da2609c authored by Oleksandr Kuzava's avatar Oleksandr Kuzava
Browse files

Issue #3350469: Replace swiftmailer and mailsystem by Symfony Mailer

parent cc2912be
No related branches found
Tags 6.0.1
No related merge requests found
......@@ -20,7 +20,9 @@ blacklist:
- minifyhtml.config
- system.logging
- system.performance
graylist: { }
graylist:
- symfony_mailer.mailer_transport.smtp
- symfony_mailer.settings
graylist_dependents: true
graylist_skip_equal: true
weight: 0
theme: default
defaults:
sender: swiftmailer
formatter: swiftmailer
modules:
swiftmailer:
none:
formatter: swiftmailer
sender: swiftmailer
langcode: en
status: true
dependencies: { }
id: sendmail
label: Sendmail
plugin: sendmail
configuration:
query:
command: ''
default_transport: sendmail
langcode: en
status: true
dependencies: { }
id: smtp
label: SMTP
plugin: smtp
configuration:
user: ''
pass: ''
host: mailhog
port: 1025
query:
verify_peer: true
local_domain: ''
restart_threshold: null
restart_threshold_sleep: null
ping_threshold: null
default_transport: smtp
......@@ -22,6 +22,7 @@ dependencies:
- http_cache_control:http_cache_control
- config_import_locale:config_import_locale
- drupal:minifyhtml
- symfony_mailer:symfony_mailer
install:
- drupal:page_cache
- drupal:dblog
......
......@@ -6,6 +6,7 @@
*/
use Drupal\captcha\Entity\CaptchaPoint;
use Drupal\Core\Config\FileStorage;
use Drupal\user\Entity\User;
/**
......@@ -77,3 +78,64 @@ function dropsolid_rocketship_profile_install() {
$redirect->save();
}
/**
* Install and configure symfony mailer.
*/
function dropsolid_rocketship_profile_update_9001() {
// If symfony mailer is already installed, do nothing.
if (\Drupal::moduleHandler()->moduleExists('symfony_mailer')) {
return;
}
/** @var \Drupal\Core\Config\StorageInterface $config_storage */
$config_storage = \Drupal::service('config.storage');
/** @var \Drupal\Core\Extension\ModuleInstallerInterface $module_installer */
$module_installer = \Drupal::service('module_installer');
// Uninstall swiftmailer with mailsystem dependency.
if (\Drupal::moduleHandler()->moduleExists('swiftmailer')) {
$module_installer->uninstall(['swiftmailer']);
}
// Install symfony mailer.
$module_installer->install(['symfony_mailer']);
// Get file storage of local config split.
$config_path = \Drupal::service('extension.list.module')->getPath('dropsolid_rocketship_profile') . '/config/splits/local';
$source = new FileStorage($config_path);
$config_names = [
'symfony_mailer.mailer_transport.smtp',
'symfony_mailer.settings',
];
// Write configs to the active storage.
foreach ($config_names as $config_name) {
$config_storage->write($config_name, $source->read($config_name));
}
$local_split = $config_storage->read('config_split.config_split.local');
// Make sure we have local config split to continue.
if (!$local_split) {
return;
}
// Support both old and new config split module versions.
$partial_list_key = isset($local_split['graylist']) ? 'graylist' : 'partial_list';
$partial_list = $local_split[$partial_list_key];
// Extend partial list with smtp transport for local environment.
foreach ($config_names as $config_name) {
if (!in_array($config_name, $partial_list)) {
$partial_list[] = $config_name;
}
}
\Drupal::configFactory()
->getEditable('config_split.config_split.local')
->set($partial_list_key, $partial_list)
->save(TRUE);
}
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