dispatch(): Argument #1 ($event) must be of type object, string given

Created on 25 October 2023, about 1 year ago

Problem/Motivation

Got an error opening layout builder after updating to Drupal 10.1

TypeError: Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch(): Argument #1 ($event) must be of type object, string given, called in /srv/websites/drupal-acc/htdocs/web/modules/contrib/layout_builder_perms/src/Access/AccessManager.php on line 207 in Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch() (regel 89 van /srv/websites/drupal-acc/htdocs/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php).

Seems like the arguments are in the wrong order, the event object should be first:

// Allow other modules to add additional contexts.
if ($plugin instanceof LayoutBuilderPermissionInterface) {
  $event = new LayoutBuilderPermissionPluginContexts($plugin, $operation, $route_match, $section_storage);
  \Drupal::service('event_dispatcher')->dispatch(
      $event,
      LayoutBuilderPermissionPluginContexts::EVENT_NAME
  );
}
🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

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

Comments & Activities

Production build 0.71.5 2024