[BUGFIX] Ensure EventDispatcher is available in installtool container 29/61329/4
authorBenjamin Franzke <bfr@qbus.de>
Fri, 19 Jul 2019 14:52:07 +0000 (16:52 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Mon, 22 Jul 2019 07:05:48 +0000 (09:05 +0200)
The Mailer class used by EnvironmentController::mailTestAction()
requires the EventDispatcher to be available. Provide it by
configuring EventDispatcher and ListenerProvider in a ServiceProvider,
which enables usage from the failsafe install-tool container.

Note: Event listeners that are registered using symfony tags
will still be added to the ServiceProvider instantiated ListenerProvider
in non-failsafe mode. The symfony generated factory will look like:

  $this->services['TYPO3\\CMS\\Core\\EventDispatcher\\ListenerProvider'] =
     $instance =
     \TYPO3\CMS\Core\ServiceProvider::getListenerProvider($this);
  $instance
    ->addListener(
      'TYPO3\\CMS\\Core\\Mail\\Event\\AfterMailerInitializationEvent',
      'TYPO3\\CMS\\Core\\Compatibility\\Slot\\PostInitializeMailer',
      NULL
    );

Resolves: #88806
Releases: master
Change-Id: I4775cc04af3d62ae08c43d762f51af31858cac2d
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61329
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/core/Classes/ServiceProvider.php
typo3/sysext/core/Configuration/Services.yaml

index dd39cf6..24a4d70 100644 (file)
@@ -34,6 +34,8 @@ class ServiceProvider extends AbstractServiceProvider
             Cache\CacheManager::class => [ static::class, 'getCacheManager' ],
             Console\CommandApplication::class => [ static::class, 'getConsoleCommandApplication' ],
             Context\Context::class => [ static::class, 'getContext' ],
+            EventDispatcher\EventDispatcher::class => [ static::class, 'getEventDispatcher' ],
+            EventDispatcher\ListenerProvider::class => [ static::class, 'getEventListenerProvider' ],
             Http\MiddlewareStackResolver::class => [ static::class, 'getMiddlewareStackResolver' ],
             Service\DependencyOrderingService::class => [ static::class, 'getDependencyOrderingService' ],
             'middlewares' => [ static::class, 'getMiddlewares' ],
@@ -67,6 +69,18 @@ class ServiceProvider extends AbstractServiceProvider
         return new Console\CommandApplication($container->get(Context\Context::class));
     }
 
+    public static function getEventDispatcher(ContainerInterface $container): EventDispatcher\EventDispatcher
+    {
+        return new EventDispatcher\EventDispatcher(
+            $container->get(EventDispatcher\ListenerProvider::class)
+        );
+    }
+
+    public static function getEventListenerProvider(ContainerInterface $container): EventDispatcher\ListenerProvider
+    {
+        return new EventDispatcher\ListenerProvider($container);
+    }
+
     public static function getDependencyOrderingService(ContainerInterface $container): Service\DependencyOrderingService
     {
         return new Service\DependencyOrderingService;
index 3ab5532..a6f5619 100644 (file)
@@ -14,13 +14,6 @@ services:
     arguments:
       $configPath: "%env(TYPO3:configPath)%/sites"
 
-  TYPO3\CMS\Core\EventDispatcher\EventDispatcher:
-    arguments:
-      $listenerProvider: '@TYPO3\CMS\Core\EventDispatcher\ListenerProvider'
-
-  TYPO3\CMS\Core\EventDispatcher\ListenerProvider:
-    public: true
-
   TYPO3\CMS\Core\Package\PackageManager:
     autoconfigure: false