Skip to content
Snippets Groups Projects
Commit 57bb8014 authored by Sergio Meneses's avatar Sergio Meneses Committed by Adam Shepherd
Browse files

Issue #3370109 by metallized, Rajab Natshah, AdamPS, kreatIL: Circular...

Issue #3370109 by metallized, Rajab Natshah, AdamPS, kreatIL: Circular reference detected for service symfony mailer config override in multilingual sites
parent 39716452
No related branches found
No related tags found
No related merge requests found
......@@ -35,24 +35,14 @@ class MailerConfigOverride implements ConfigFactoryOverrideInterface {
*/
protected $moduleHandler;
/**
* The email builder manager.
*
* @var \Drupal\symfony_mailer\Processor\EmailBuilderManagerInterface
*/
protected $builderManager;
/**
* Constructs the MailerConfigOverride object.
*
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
* @param \Drupal\symfony_mailer\Processor\EmailBuilderManagerInterface $email_builder_manager
* The email builder manager.
*/
public function __construct(ModuleHandlerInterface $module_handler, EmailBuilderManagerInterface $email_builder_manager) {
public function __construct(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
$this->builderManager = $email_builder_manager;
}
/**
......@@ -94,7 +84,12 @@ class MailerConfigOverride implements ConfigFactoryOverrideInterface {
// loop by marking the cache as built before starting.
$this->builtCache = TRUE;
foreach ($this->builderManager->getDefinitions() as $definition) {
// We cannot use dependency injection because that creates a circular
// dependency.
/** @var \Drupal\symfony_mailer\Processor\EmailBuilderManagerInterface $builderManager */
$builderManager = \Drupal::service('plugin.manager.email_builder');
foreach ($builderManager->getDefinitions() as $definition) {
$this->configOverrides = array_merge($this->configOverrides, $definition['config_overrides']);
}
}
......
......@@ -30,6 +30,6 @@ services:
- { name: service_collector, tag: mailer.transport_factory, call: addFactory }
symfony_mailer.config_override:
class: Drupal\symfony_mailer\Processor\MailerConfigOverride
arguments: ['@module_handler', '@plugin.manager.email_builder']
arguments: ['@module_handler']
tags:
- {name: config.factory.override}
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