Problem/Motivation
After installing the module and navigating to /admin/config/people/pcp, the site throws a fatal error instead of displaying the configuration form:
ArgumentCountError: Too few arguments to function Drupal\Core\Form\ConfigFormBase::__construct(), 1 passed in /var/www/html/xxxxxxx/web/modules/contrib/pcp/src/Form/PCPForm.php on line 33 and exactly 2 expected in Drupal\Core\Form\ConfigFormBase->__construct() (line 45 of /var/www/html/xxxxxxx/web/core/lib/Drupal/Core/Form/ConfigFormBase.php).
Steps to reproduce
- Install the pcp module on a Drupal 11.4.
- Navigate to
/admin/config/people/pcp.
- Observe the fatal error above instead of the settings form.
Proposed resolution
In PCPForm.php:
1. Add the import:
use Drupal\Core\Config\TypedConfigManagerInterface;
2. Update the constructor to accept and forward the typed config manager:
public function __construct(
ConfigFactoryInterface $config_factory,
TypedConfigManagerInterface $typed_config_manager
) {
parent::__construct($config_factory, $typed_config_manager);
}
3. Update create() to inject the new service:
public static function create(ContainerInterface $container) {
return new static(
$container->get('config.factory'),
$container->get('config.typed')
);
}
Comments
Comment #4
garvitasakhrani commentedUpdated PCPForm to inject the typed config manager required by Drupal 11, resolving the ConfigFormBase::__construct() ArgumentCountError.
Please review. Thanks!