Type Error on ContainerAwareEventDispatcher

Created on 30 January 2025, 24 days ago

Problem/Motivation

It seems that https://www.drupal.org/node/3376090 hit the module. On a fresh Drupal CMS / Drupal11(?) I installed this module and got this error. Changing the module accordingly fixes the problem.

TypeError: Drupal\views_json_source\Plugin\views\query\ViewsJsonQuery::__construct(): Argument #7 ($event_dispatcher) must be of type Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher, Symfony\Component\EventDispatcher\EventDispatcher given, called in /***/web/modules/contrib/views_json_source/src/Plugin/views/query/ViewsJsonQuery.php on line 145 in Drupal\views_json_source\Plugin\views\query\ViewsJsonQuery->__construct() (line 129 of /****/web/modules/contrib/views_json_source/src/Plugin/views/query/ViewsJsonQuery.php).

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇩🇪Germany rogerpfaff Munich

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

Comments & Activities

  • Issue created by @rogerpfaff
  • 🇪🇸Spain leandro713 🇪🇸 Madrid 🤠

    yes, just change

    use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher;
    

    for

    use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
    

    and change the constructor like:

    public function __construct(
      array $configuration,
      $plugin_id,
      $plugin_definition,
      ConfigFactoryInterface $config,
      CacheBackendInterface $cache,
      TimeInterface $time,
      EventDispatcherInterface $event_dispatcher, // <-- here the magic
      ClientInterface $http_client,
      Token $token,
      LoggerInterface $logger
    ) {
      parent::__construct($configuration, $plugin_id, $plugin_definition);
    
      $this->config = $config;
      $this->cache = $cache;
      $this->time = $time;
      $this->eventDispatcher = $event_dispatcher;
      $this->httpClient = $http_client;
      $this->token = $token;
      $this->logger = $logger;
    }
    

    and done :-D

Production build 0.71.5 2024