DomainLanguageOverrider::__construct(): Argument #1 ($current_user) must be of type AccountProxyInterface

Created on 19 September 2023, about 2 years ago

Problem/Motivation

The commit that fixed the issue in πŸ“Œ \Drupal calls should be avoided in classes, use dependency injection instead Fixed seems to have caused an error. In that, cslevy comments:

Fatal error: Uncaught TypeError: Drupal\domain_language\DomainLanguageOverrider::__construct(): Argument #1 ($current_user) must be of type Drupal\Core\Session\AccountProxyInterface, Drupal\Core\Config\CachedStorage given, called in .../web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 and defined in .../web/modules/contrib/domain_language/src/DomainLanguageOverrider.php:81

This class is defined in the services in the following way:

  domain_language.overrider:
    class: Drupal\domain_language\DomainLanguageOverrider
    tags:
      - { name: config.factory.override, priority: -140 }
    arguments: ['@config.storage']
And also the create method was introduced.
/**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static(
      $container->get('current_user'),
      $container->get('domain.negotiator'),
      $container->get('config.factory'),
      $container->get('domain_config.overrider')
    );
  }
We don't need both. I think the dependencies should be defined in the services.yml, and this create method removed.
πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bburg Washington, DC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024