Unverified Commit bd4c5f07 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3055194 by catch, mikelutz, longwave, mkalkbrenner, hchonov: [Symfony...

Issue #3055194 by catch, mikelutz, longwave, mkalkbrenner, hchonov: [Symfony 5] The signature of the "Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch()" method should be updated to "dispatch($event, string $eventName = null)", not doing so is deprecated since Symfony 4.3
parent 065f4812
Loading
Loading
Loading
Loading
+15 −3
Original line number Diff line number Diff line
@@ -6,6 +6,8 @@
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\EventDispatcher\Event as ContractsEvent;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface;

/**
 * A performance optimized container aware event dispatcher.
@@ -86,9 +88,19 @@ public function __construct(ContainerInterface $container, array $listeners = []
  /**
   * {@inheritdoc}
   */
  public function dispatch($event_name, Event $event = NULL) {
    if ($event === NULL) {
      $event = new Event();
  public function dispatch($event/*, string $event_name = NULL*/) {
    $event_name = 1 < \func_num_args() ? func_get_arg(1) : NULL;
    if (\is_object($event)) {
      $event_name = $event_name ?? \get_class($event);
    }
    elseif (\is_string($event) && (NULL === $event_name || $event_name instanceof ContractsEvent || $event_name instanceof Event)) {
      @trigger_error('Calling the Symfony\Component\EventDispatcher\EventDispatcherInterface::dispatch() method with a string event name as the first argument is deprecated in drupal:9.1.0, an Event object will be required instead in drupal:10.0.0. See https://www.drupal.org/node/3154407', E_USER_DEPRECATED);
      $swap = $event;
      $event = $event_name ?? new Event();
      $event_name = $swap;
    }
    else {
      throw new \TypeError(sprintf('Argument 1 passed to "%s::dispatch()" must be an object, %s given.', ContractsEventDispatcherInterface::class, \gettype($event)));
    }

    if (isset($this->listeners[$event_name])) {
+2 −1
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@
  "require": {
    "php": ">=7.3.0",
    "symfony/dependency-injection": "^4.4",
    "symfony/event-dispatcher": "^4.4"
    "symfony/event-dispatcher": "^4.4",
    "symfony/event-dispatcher-contracts": "^1.1"
  },
  "autoload": {
    "psr-4": {
+2 −2
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ public function save($has_trusted_data = FALSE) {
      Cache::invalidateTags($this->getCacheTags());
    }
    $this->isNew = FALSE;
    $this->eventDispatcher->dispatch(ConfigEvents::SAVE, new ConfigCrudEvent($this));
    $this->eventDispatcher->dispatch(new ConfigCrudEvent($this), ConfigEvents::SAVE);
    $this->originalData = $this->data;
    return $this;
  }
@@ -245,7 +245,7 @@ public function delete() {
    Cache::invalidateTags($this->getCacheTags());
    $this->isNew = TRUE;
    $this->resetOverriddenData();
    $this->eventDispatcher->dispatch(ConfigEvents::DELETE, new ConfigCrudEvent($this));
    $this->eventDispatcher->dispatch(new ConfigCrudEvent($this), ConfigEvents::DELETE);
    $this->originalData = $this->data;
    return $this;
  }
+1 −1
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ public function rename($old_name, $new_name) {

    // Prime the cache and load the configuration with the correct overrides.
    $config = $this->get($new_name);
    $this->eventDispatcher->dispatch(ConfigEvents::RENAME, new ConfigRenameEvent($config, $old_name));
    $this->eventDispatcher->dispatch(new ConfigRenameEvent($config, $old_name), ConfigEvents::RENAME);
    return $this;
  }

+3 −3
Original line number Diff line number Diff line
@@ -640,7 +640,7 @@ protected function processMissingContent(&$context) {
    if (!empty($missing_content)) {
      $event = new MissingContentEvent($missing_content);
      // Fire an event to allow listeners to create the missing content.
      $this->eventDispatcher->dispatch(ConfigEvents::IMPORT_MISSING_CONTENT, $event);
      $this->eventDispatcher->dispatch($event, ConfigEvents::IMPORT_MISSING_CONTENT);
      $sandbox['missing_content']['data'] = $event->getMissingContent();
    }
    $current_count = count($sandbox['missing_content']['data']);
@@ -660,7 +660,7 @@ protected function processMissingContent(&$context) {
   *   The batch context.
   */
  protected function finish(&$context) {
    $this->eventDispatcher->dispatch(ConfigEvents::IMPORT, new ConfigImporterEvent($this));
    $this->eventDispatcher->dispatch(new ConfigImporterEvent($this), ConfigEvents::IMPORT);
    // The import is now complete.
    $this->lock->release(static::LOCK_NAME);
    $this->reset();
@@ -742,7 +742,7 @@ public function validate() {
          $this->logError($this->t('Rename operation for simple configuration. Existing configuration @old_name and staged configuration @new_name.', ['@old_name' => $names['old_name'], '@new_name' => $names['new_name']]));
        }
      }
      $this->eventDispatcher->dispatch(ConfigEvents::IMPORT_VALIDATE, new ConfigImporterEvent($this));
      $this->eventDispatcher->dispatch(new ConfigImporterEvent($this), ConfigEvents::IMPORT_VALIDATE);
      if (count($this->getErrors())) {
        $errors = array_merge(['There were errors validating the config synchronization.'], $this->getErrors());
        throw new ConfigImporterException(implode(PHP_EOL, $errors));
Loading