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

Created on 25 October 2023, 8 months 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.69.0 2024