Commit 85af8d75 authored by Tim Rohaly's avatar Tim Rohaly Committed by Tim Rohaly
Browse files

Issue #3259445 by TR: Symfony\Component\EventDispatcher\Event is deprecated in drupal:9.1.0

parent d8244cab
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
        "source": "https://git.drupalcode.org/project/rules"
    },
    "require": {
        "drupal/core": "^9 || ^10",
        "drupal/core": "^9.1 || ^10",
        "drupal/typed_data": "^1.0"
    },
    "minimum-stability": "dev",
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ name: Rules
type: module
description: 'React on events and conditionally evaluate actions.'
package: Rules
core_version_requirement: ^9 || ^10
core_version_requirement: ^9.1 || ^10
dependencies:
  - drupal:config
  - typed_data:typed_data
+7 −3
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ namespace Drupal\rules\Core;

use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\EventDispatcher\Event;

/**
 * Interface for handling configurable rules events.
@@ -29,8 +28,13 @@ interface RulesConfigurableEventHandlerInterface extends RulesEventHandlerInterf
  /**
   * Determines the qualified event names for the dispatched event.
   *
   * @param \Symfony\Component\EventDispatcher\Event $event
   * @todo The 'object' type hint should be replaced with the appropriate
   * class once Symfony 4 is no longer supported.
   *
   * @param object $event
   *   The event data of the event being dispatched.
   *   In Drupal 9 this will be a \Symfony\Component\EventDispatcher\Event,
   *   In Drupal 10 this will be a \Symfony\Contracts\EventDispatcher\Event.
   * @param string $event_name
   *   The event base name.
   * @param array $event_definition
@@ -42,7 +46,7 @@ interface RulesConfigurableEventHandlerInterface extends RulesEventHandlerInterf
   *   the fully-qualified event "rules_entity_view:node--article" should be
   *   triggered in addition to base event "rules_entity_view:node".
   */
  public static function determineQualifiedEvents(Event $event, $event_name, array &$event_definition);
  public static function determineQualifiedEvents(object $event, $event_name, array &$event_definition);

  /**
   * Provides a human readable summary of the event's configuration.
+3 −2
Original line number Diff line number Diff line
@@ -4,7 +4,6 @@ namespace Drupal\rules\EventHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\rules\Event\EntityEvent;
use Symfony\Component\EventDispatcher\Event;

/**
 * Exposes the bundle of an entity as event setting.
@@ -14,7 +13,9 @@ class ConfigurableEventHandlerEntityBundle extends ConfigurableEventHandlerBase
  /**
   * {@inheritdoc}
   */
  public static function determineQualifiedEvents(Event $event, $event_name, array &$event_definition) {
  public static function determineQualifiedEvents(object $event, $event_name, array &$event_definition) {
    // @todo The 'object' type hint should be replaced with the appropriate
    // class once Symfony 4 is no longer supported.
    $events_suffixes = [];
    if ($event instanceof EntityEvent) {
      $events_suffixes[] = $event->getSubject()->bundle();
+14 −3
Original line number Diff line number Diff line
@@ -8,9 +8,10 @@ use Drupal\rules\Context\ExecutionState;
use Drupal\rules\Core\RulesConfigurableEventHandlerInterface;
use Drupal\rules\Core\RulesEventManager;
use Drupal\rules\Engine\RulesComponentRepositoryInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
use Symfony\Component\EventDispatcher\Event as SymfonyComponentEvent;
use Symfony\Contracts\EventDispatcher\Event as SymfonyContractsEvent;

/**
 * Subscribes to Symfony events and maps them to Rules events.
@@ -97,12 +98,22 @@ class GenericEventSubscriber implements EventSubscriberInterface {
  /**
   * Reacts on the given event and invokes configured reaction rules.
   *
   * @param \Symfony\Component\EventDispatcher\Event $event
   * @param object $event
   *   The event object containing context for the event.
   *   In Drupal 9 this will be a \Symfony\Component\EventDispatcher\Event,
   *   In Drupal 10 this will be a \Symfony\Contracts\EventDispatcher\Event.
   * @param string $event_name
   *   The event name.
   */
  public function onRulesEvent(Event $event, $event_name) {
  public function onRulesEvent(object $event, $event_name) {
    // @todo The 'object' type hint should be replaced with the appropriate
    // class once Symfony 4 is no longer supported, and the assert() should be
    // removed.
    assert(
      $event instanceof SymfonyComponentEvent ||
      $event instanceof SymfonyContractsEvent
    );

    // Get event metadata and the to-be-triggered events.
    $event_definition = $this->eventManager->getDefinition($event_name);
    $handler_class = $event_definition['class'];