Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f17d2ec

Browse files
committed
[EventDispatcher] Deprecate LegacyEventDispatcherProxy.
1 parent 8c80c5b commit f17d2ec

16 files changed

+32
-35
lines changed

UPGRADE-5.1.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
UPGRADE FROM 5.0 to 5.1
22
=======================
33

4+
EventDispatcher
5+
---------------
6+
7+
* Deprecated `LegacyEventDispatcherProxy`. Use the event dispatcher without the proxy.
8+
49
FrameworkBundle
510
---------------
611

UPGRADE-6.0.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
UPGRADE FROM 5.x to 6.0
22
=======================
33

4+
EventDispatcher
5+
---------------
6+
7+
* Removed `LegacyEventDispatcherProxy`. Use the event dispatcher without the proxy.
8+
49
FrameworkBundle
510
---------------
611

src/Symfony/Component/EventDispatcher/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
5.1.0
5+
-----
6+
7+
* The `LegacyEventDispatcherProxy` class has been deprecated.
8+
49
5.0.0
510
-----
611

src/Symfony/Component/EventDispatcher/LegacyEventDispatcherProxy.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
/**
1717
* A helper class to provide BC/FC with the legacy signature of EventDispatcherInterface::dispatch().
1818
*
19-
* This class should be deprecated in Symfony 5.1
20-
*
2119
* @author Nicolas Grekas <[email protected]>
20+
*
21+
* @deprecated since Symfony 5.1.
2222
*/
2323
final class LegacyEventDispatcherProxy
2424
{
2525
public static function decorate(?EventDispatcherInterface $dispatcher): ?EventDispatcherInterface
2626
{
27+
@trigger_error(sprintf('%s is deprecated. Use the event dispatcher without the proxy.', __CLASS__), E_USER_DEPRECATED);
28+
2729
return $dispatcher;
2830
}
2931
}

src/Symfony/Component/Mailer/Mailer.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\Mailer;
1313

14-
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1514
use Symfony\Component\Mailer\Event\MessageEvent;
1615
use Symfony\Component\Mailer\Messenger\SendEmailMessage;
1716
use Symfony\Component\Mailer\Transport\TransportInterface;
@@ -32,7 +31,7 @@ public function __construct(TransportInterface $transport, MessageBusInterface $
3231
{
3332
$this->transport = $transport;
3433
$this->bus = $bus;
35-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
34+
$this->dispatcher = $dispatcher;
3635
}
3736

3837
public function send(RawMessage $message, Envelope $envelope = null): void

src/Symfony/Component/Mailer/Transport/AbstractTransport.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Log\LoggerInterface;
1515
use Psr\Log\NullLogger;
16-
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1716
use Symfony\Component\Mailer\Envelope;
1817
use Symfony\Component\Mailer\Event\MessageEvent;
1918
use Symfony\Component\Mailer\SentMessage;
@@ -33,7 +32,7 @@ abstract class AbstractTransport implements TransportInterface
3332

3433
public function __construct(EventDispatcherInterface $dispatcher = null, LoggerInterface $logger = null)
3534
{
36-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
35+
$this->dispatcher = $dispatcher;
3736
$this->logger = $logger ?: new NullLogger();
3837
}
3938

src/Symfony/Component/Mailer/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": "^7.2.5",
2020
"egulias/email-validator": "^2.1.10",
2121
"psr/log": "~1.0",
22-
"symfony/event-dispatcher": "^4.4|^5.0",
22+
"symfony/event-dispatcher": "^5.0",
2323
"symfony/mime": "^4.4|^5.0",
2424
"symfony/service-contracts": "^1.1|^2"
2525
},

src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Psr\Log\LoggerAwareTrait;
1515
use Psr\Log\NullLogger;
16-
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1716
use Symfony\Component\Messenger\Envelope;
1817
use Symfony\Component\Messenger\Event\SendMessageToTransportsEvent;
1918
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
@@ -35,13 +34,7 @@ class SendMessageMiddleware implements MiddlewareInterface
3534
public function __construct(SendersLocatorInterface $sendersLocator, EventDispatcherInterface $eventDispatcher = null)
3635
{
3736
$this->sendersLocator = $sendersLocator;
38-
39-
if (null !== $eventDispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
40-
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
41-
} else {
42-
$this->eventDispatcher = $eventDispatcher;
43-
}
44-
37+
$this->eventDispatcher = $eventDispatcher;
4538
$this->logger = new NullLogger();
4639
}
4740

src/Symfony/Component/Messenger/Worker.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Messenger;
1313

1414
use Psr\Log\LoggerInterface;
15-
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1615
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
1716
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;
1817
use Symfony\Component\Messenger\Event\WorkerMessageReceivedEvent;
@@ -48,12 +47,7 @@ public function __construct(array $receivers, MessageBusInterface $bus, EventDis
4847
$this->receivers = $receivers;
4948
$this->bus = $bus;
5049
$this->logger = $logger;
51-
52-
if (null !== $eventDispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
53-
$this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher);
54-
} else {
55-
$this->eventDispatcher = $eventDispatcher;
56-
}
50+
$this->eventDispatcher = $eventDispatcher;
5751
}
5852

5953
/**

src/Symfony/Component/Messenger/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"doctrine/persistence": "^1.3",
2626
"symfony/console": "^4.4|^5.0",
2727
"symfony/dependency-injection": "^4.4|^5.0",
28-
"symfony/event-dispatcher": "^4.4|^5.0",
28+
"symfony/event-dispatcher": "^5.0",
2929
"symfony/http-kernel": "^4.4|^5.0",
3030
"symfony/process": "^4.4|^5.0",
3131
"symfony/property-access": "^4.4|^5.0",
@@ -36,7 +36,7 @@
3636
},
3737
"conflict": {
3838
"doctrine/persistence": "<1.3",
39-
"symfony/event-dispatcher": "<4.4",
39+
"symfony/event-dispatcher": "<5",
4040
"symfony/framework-bundle": "<4.4",
4141
"symfony/http-kernel": "<4.4"
4242
},

src/Symfony/Component/Notifier/Chatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(TransportInterface $transport, MessageBusInterface $
3333
{
3434
$this->transport = $transport;
3535
$this->bus = $bus;
36-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
36+
$this->dispatcher = \class_exists(LegacyEventDispatcherProxy::class) && \is_a(LegacyEventDispatcherProxy::class, EventDispatcherInterface::class, true) ? LegacyEventDispatcherProxy::decorate($dispatcher) : $dispatcher;
3737
}
3838

3939
public function __toString(): string

src/Symfony/Component/Notifier/Texter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(TransportInterface $transport, MessageBusInterface $
3333
{
3434
$this->transport = $transport;
3535
$this->bus = $bus;
36-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
36+
$this->dispatcher = \class_exists(LegacyEventDispatcherProxy::class) && \is_a(LegacyEventDispatcherProxy::class, EventDispatcherInterface::class, true) ? LegacyEventDispatcherProxy::decorate($dispatcher) : $dispatcher;
3737
}
3838

3939
public function __toString(): string

src/Symfony/Component/Notifier/Transport/AbstractTransport.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct(HttpClientInterface $client = null, EventDispatcherI
4545
$this->client = HttpClient::create();
4646
}
4747

48-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
48+
$this->dispatcher = \class_exists(LegacyEventDispatcherProxy::class) && \is_a(LegacyEventDispatcherProxy::class, EventDispatcherInterface::class, true) ? LegacyEventDispatcherProxy::decorate($dispatcher) : $dispatcher;
4949
}
5050

5151
/**

src/Symfony/Component/Notifier/Transport/AbstractTransportFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class AbstractTransportFactory implements TransportFactoryInterface
3030

3131
public function __construct(EventDispatcherInterface $dispatcher = null, HttpClientInterface $client = null)
3232
{
33-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
33+
$this->dispatcher = \class_exists(LegacyEventDispatcherProxy::class) && \is_a(LegacyEventDispatcherProxy::class, EventDispatcherInterface::class, true) ? LegacyEventDispatcherProxy::decorate($dispatcher) : $dispatcher;
3434
$this->client = $client;
3535
}
3636

src/Symfony/Component/Security/Http/Firewall/ContextListener.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\Security\Http\Firewall;
1313

1414
use Psr\Log\LoggerInterface;
15-
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
1615
use Symfony\Component\HttpFoundation\Request;
1716
use Symfony\Component\HttpFoundation\Session\Session;
1817
use Symfony\Component\HttpKernel\Event\RequestEvent;
@@ -66,12 +65,7 @@ public function __construct(TokenStorageInterface $tokenStorage, iterable $userP
6665
$this->userProviders = $userProviders;
6766
$this->sessionKey = '_security_'.$contextKey;
6867
$this->logger = $logger;
69-
70-
if (null !== $dispatcher && class_exists(LegacyEventDispatcherProxy::class)) {
71-
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
72-
} else {
73-
$this->dispatcher = $dispatcher;
74-
}
68+
$this->dispatcher = $dispatcher;
7569

7670
$this->trustResolver = $trustResolver ?: new AuthenticationTrustResolver(AnonymousToken::class, RememberMeToken::class);
7771
$this->sessionTrackerEnabler = $sessionTrackerEnabler;

src/Symfony/Component/Security/Http/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"psr/log": "~1.0"
2929
},
3030
"conflict": {
31+
"symfony/event-dispatcher": "<5",
3132
"symfony/security-csrf": "<4.4"
3233
},
3334
"suggest": {

0 commit comments

Comments
 (0)