- Issue created by @netgeek123
- First commit to issue fork.
- Merge request !67Issue #3508548: Fix for ConfigFormBase::__construct() error → (Open) created by Unnamed author
Drupal 11 introduced changes in how ConfigFormBase is structured. The constructor now requires two arguments:
ArgumentCountError: Too few arguments to function Drupal\Core\Form\ConfigFormBase::__construct(), 1 passed in ......./modules/contrib/anu_lms/src/Form/LabelsForm.php on line 32 and exactly 2 expected in Drupal\Core\Form\ConfigFormBase->__construct() (line 44 of ........../core/lib/Drupal/Core/Form/ConfigFormBase.php).
Fixed:
use Drupal\Core\Config\TypedConfigManagerInterface;
/**
* AdminToolbarToolsSettingsForm constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The factory for configuration objects.
* @param \Drupal\anu_lms\Settings $settings
* The Settings instance.
*/
public function __construct(
ConfigFactoryInterface $configFactory,
TypedConfigManagerInterface $typedConfigManager,
Settings $settings
) {
parent::__construct($configFactory, $typedConfigManager);
$this->settings = $settings;
}
And fixed create()
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed'), // Use 'config.typed' instead of 'module_handler'
$container->get('anu_lms.settings')
);
}
This will fix the error that shows in 11.1.3
Active
2.11
Code