Skip to content
Snippets Groups Projects

Issue #3512158: Updated HtmlMailConfigurationForm.php .

Open Arun Sahijpal requested to merge issue/htmlmail-3512158:3512158-too-few-arguments into 4.0.x
1 file
+ 22
7
Compare changes
  • Side-by-side
  • Inline
@@ -2,12 +2,13 @@
@@ -2,12 +2,13 @@
namespace Drupal\htmlmail\Form;
namespace Drupal\htmlmail\Form;
 
use Drupal\htmlmail\Helper\HtmlMailHelper;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ConfigFactoryInterface;
 
use Drupal\Core\Config\TypedConfigManagerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\htmlmail\Helper\HtmlMailHelper;
/**
/**
* Class HtmlMailConfigurationForm.
* Class HtmlMailConfigurationForm.
@@ -17,22 +18,31 @@ use Drupal\htmlmail\Helper\HtmlMailHelper;
@@ -17,22 +18,31 @@ use Drupal\htmlmail\Helper\HtmlMailHelper;
class HtmlMailConfigurationForm extends ConfigFormBase {
class HtmlMailConfigurationForm extends ConfigFormBase {
/**
/**
* The module_handler service.
* The module handler service.
*
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
*/
protected $moduleHandler;
protected ModuleHandlerInterface $moduleHandler;
/**
/**
* HtmlMailConfigurationForm constructor.
* HtmlMailConfigurationForm constructor.
*
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* Config factory service, injected into constructor.
* Config factory service.
 
* @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config_manager
 
* Typed config manager service.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* Module Handler service, injected into constructor.
* Module handler service.
*/
*/
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler) {
parent::__construct($config_factory);
public function __construct(ConfigFactoryInterface $config_factory, $typed_config_manager_or_messenger, ModuleHandlerInterface $module_handler) {
 
// Check if the second argument is TypedConfigManagerInterface (Drupal 10.2+)
 
if ($typed_config_manager_or_messenger instanceof TypedConfigManagerInterface) {
 
parent::__construct($config_factory, $typed_config_manager_or_messenger);
 
}
 
else {
 
parent::__construct($config_factory);
 
}
$this->moduleHandler = $module_handler;
$this->moduleHandler = $module_handler;
}
}
@@ -40,8 +50,13 @@ class HtmlMailConfigurationForm extends ConfigFormBase {
@@ -40,8 +50,13 @@ class HtmlMailConfigurationForm extends ConfigFormBase {
* {@inheritdoc}
* {@inheritdoc}
*/
*/
public static function create(ContainerInterface $container) {
public static function create(ContainerInterface $container) {
 
$typed_config_manager_or_messenger = $container->has('config.typed')
 
? $container->get('config.typed')
 
: null;
 
return new static(
return new static(
$container->get('config.factory'),
$container->get('config.factory'),
 
$typed_config_manager_or_messenger,
$container->get('module_handler')
$container->get('module_handler')
);
);
}
}
Loading