Commit d1c77ea5 authored by Benjamin Franzke's avatar Benjamin Franzke
Browse files

[BUGFIX] Add support for symfony/event-dispatcher-contracts v1

With the introduction of symfony/event-dispatcher-contracts
in https://git.typo3.org/Packages/TYPO3.CMS.git/commit/e4a1ae8762ee99712
we forced usage of symfony5 in composer-based installations where
installation with symfony4 was possible before. This is because event
contracts v2 is only compatible with symfony v5, but contracts v1 needs to
be supported for symfony4 compatibility.

Note: although non-composer-based installations used symfony5 bundled
already, composer mode could still use symfony v4 if needed.

We now add a new intermediate composer package that is available in two
different versions, and offers a compatible symfony event dispatcher
adapter for the respective interfaces in symfony v4 and symfony v5 in each
of these version. typo3/cms-core allows to install both versions which
means we can provide a compatible adapter for both, symfony v4 and v5.

This change allows composer-based installations to support both
versions (v5/v4) again, so extensions like EXT:solr (which requires
a package called solarium) to work with the dependency constraints
of TYPO3 Core.

Commands used:

  composer require --no-update --working-dir=typo3/sysext/core \
    "symfony/event-dispatcher-contracts:^1.1 || ^2.0" \
    "typo3/symfony-psr-event-dispatcher-adapter:^1.0 || ^2.0"

  composer require --no-update \
    "symfony/event-dispatcher-contracts:^1.1 || ^2.0" \
    "typo3/symfony-psr-event-dispatcher-adapter:^1.0 || ^2.0"

  composer update --lock

Resolves: #92229
Releases: master, 10.4
Change-Id: I4ff6c6589833cbfea3c4b327a8580fd5fbf45468
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/65644


Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: Helmut Hummel's avatarHelmut Hummel <typo3@helhum.io>
Tested-by: Simon Gilli's avatarSimon Gilli <typo3@gilbertsoft.org>
Tested-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
Reviewed-by: Simon Gilli's avatarSimon Gilli <typo3@gilbertsoft.org>
Reviewed-by: Helmut Hummel's avatarHelmut Hummel <typo3@helhum.io>
Reviewed-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
parent e1ab7023
......@@ -58,7 +58,7 @@
"symfony/config": "^4.4 || ^5.0",
"symfony/console": "^4.4 || ^5.0",
"symfony/dependency-injection": "^4.4 || ^5.0",
"symfony/event-dispatcher-contracts": "^2.0",
"symfony/event-dispatcher-contracts": "^1.1 || ^2.0",
"symfony/expression-language": "^4.4 || ^5.0",
"symfony/finder": "^4.4 || ^5.0",
"symfony/http-foundation": "^4.4 || ^5.0",
......@@ -76,6 +76,7 @@
"typo3/cms-cli": "^2.0",
"typo3/cms-composer-installers": "^2.0 || ^3.0",
"typo3/phar-stream-wrapper": "^3.1.3",
"typo3/symfony-psr-event-dispatcher-adapter": "^1.0 || ^2.0",
"typo3fluid/fluid": "^2.6.8 || ^3"
},
"require-dev": {
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3f1c87b5cfbc1709b5c8741eff521bac",
"content-hash": "e2911ef42adea533e947f376bc311cc3",
"packages": [
{
"name": "cogpowered/finediff",
......@@ -3654,6 +3654,45 @@
],
"time": "2019-10-18T11:57:16+00:00"
},
{
"name": "typo3/symfony-psr-event-dispatcher-adapter",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/TYPO3/symfony-psr-event-dispatcher-adapter.git",
"reference": "6ea13090471966f2fb5de933e5cd5edd4f5d2327"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/TYPO3/symfony-psr-event-dispatcher-adapter/zipball/6ea13090471966f2fb5de933e5cd5edd4f5d2327",
"reference": "6ea13090471966f2fb5de933e5cd5edd4f5d2327",
"shasum": ""
},
"require": {
"php": "^7.2",
"psr/event-dispatcher": "^1.0",
"symfony/event-dispatcher-contracts": "^2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"TYPO3\\SymfonyPsrEventDispatcherAdapter\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "Adapter to provide compatibility with the Symfony's event dispatcher interface in all versions with the PSR-14 specification.",
"homepage": "https://typo3.org/",
"keywords": [
"adapter",
"events",
"psr",
"psr-14"
],
"time": "2020-09-09T20:23:21+00:00"
},
{
"name": "typo3fluid/fluid",
"version": "2.6.9",
......
<?php
declare(strict_types=1);
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
namespace TYPO3\CMS\Core\Adapter;
use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as SymfonyEventDispatcherInterface;
/**
* @internal
*/
class SymfonyEventDispatcher implements SymfonyEventDispatcherInterface
{
/**
* @var EventDispatcherInterface
*/
private $eventDispatcher;
public function __construct(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
}
/**
* @inheritdoc
*/
public function dispatch(object $event, string $eventName = null): object
{
return $this->eventDispatcher->dispatch($event);
}
}
......@@ -23,6 +23,7 @@ use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as SymfonyEventDispatcherInterface;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Package\AbstractServiceProvider;
use TYPO3\SymfonyPsrEventDispatcherAdapter\EventDispatcherAdapter as SymfonyEventDispatcher;
/**
* @internal
......@@ -37,7 +38,7 @@ class ServiceProvider extends AbstractServiceProvider
public function getFactories(): array
{
return [
Adapter\SymfonyEventDispatcher::class => [ static::class, 'getSymfonyEventDispatcher' ],
SymfonyEventDispatcher::class => [ static::class, 'getSymfonyEventDispatcher' ],
Cache\CacheManager::class => [ static::class, 'getCacheManager' ],
Charset\CharsetConverter::class => [ static::class, 'getCharsetConverter' ],
Configuration\SiteConfiguration::class => [ static::class, 'getSiteConfiguration' ],
......@@ -85,7 +86,7 @@ class ServiceProvider extends AbstractServiceProvider
public static function getSymfonyEventDispatcher(ContainerInterface $container): SymfonyEventDispatcherInterface
{
return self::new($container, Adapter\SymfonyEventDispatcher::class, [
return self::new($container, SymfonyEventDispatcher::class, [
$container->get(EventDispatcherInterface::class)
]);
}
......@@ -213,7 +214,7 @@ class ServiceProvider extends AbstractServiceProvider
public static function getMailTransportFactory(ContainerInterface $container): Mail\TransportFactory
{
return self::new($container, Mail\TransportFactory::class, [
$container->get(Adapter\SymfonyEventDispatcher::class),
$container->get(SymfonyEventDispatcher::class),
$container->get(Log\LogManager::class)
]);
}
......
......@@ -212,7 +212,7 @@ services:
alias: GuzzleHttp\Client
public: true
Symfony\Contracts\EventDispatcher\EventDispatcherInterface:
alias: TYPO3\CMS\Core\Adapter\SymfonyEventDispatcher
alias: TYPO3\SymfonyPsrEventDispatcherAdapter\EventDispatcherAdapter
public: true
# External dependencies
......
......@@ -45,7 +45,7 @@
"symfony/config": "^4.4 || ^5.0",
"symfony/console": "^4.4 || ^5.0",
"symfony/dependency-injection": "^4.4 || ^5.0",
"symfony/event-dispatcher-contracts": "^2.0",
"symfony/event-dispatcher-contracts": "^1.1 || ^2.0",
"symfony/expression-language": "^4.4 || ^5.0",
"symfony/finder": "^4.4 || ^5.0",
"symfony/http-foundation": "^4.4 || ^5.0",
......@@ -60,6 +60,7 @@
"typo3/cms-cli": "^2.0",
"typo3/cms-composer-installers": "^2.0 || ^3.0",
"typo3/phar-stream-wrapper": "^3.1.3",
"typo3/symfony-psr-event-dispatcher-adapter": "^1.0 || ^2.0",
"typo3fluid/fluid": "^2.6.8 || ^3"
},
"require-dev": {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment