Skip to content

Commit 6817cde

Browse files
annuhJean85
andauthored
Fixes #354 Add class_exists before aliasing class (#356)
* Use 3.5.x branch * Update CHANGELOG.md * Fix PHP-CS issues * Improve changelog message Co-authored-by: Alessandro Lai <[email protected]>
1 parent fcdd644 commit 6817cde

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## Unreleased
88
- Use `jean85/pretty-package-versions` `^1.5` to leverage the new `getRootPackageVersion` method (c8799ac)
9+
- Fix support for PHP preloading (#354, thanks to @annuh)
910

1011
## 3.5.1 (2020-05-07)
1112
- Capture events using the `Hub` in the `MessengerListener` to avoid loosing `Scope` data (#339, thanks to @sh41)

src/EventListener/RequestListener.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,19 @@
1414
use Symfony\Component\Security\Core\User\UserInterface;
1515

1616
if (Kernel::MAJOR_VERSION >= 5) {
17-
class_alias(RequestEvent::class, RequestListenerRequestEvent::class);
18-
class_alias(ControllerEvent::class, RequestListenerControllerEvent::class);
17+
if (! class_exists(RequestListenerRequestEvent::class, false)) {
18+
class_alias(RequestEvent::class, RequestListenerRequestEvent::class);
19+
}
20+
if (! class_exists(RequestListenerControllerEvent::class, false)) {
21+
class_alias(ControllerEvent::class, RequestListenerControllerEvent::class);
22+
}
1923
} else {
20-
class_alias(GetResponseEvent::class, RequestListenerRequestEvent::class);
21-
class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class);
24+
if (! class_exists(RequestListenerRequestEvent::class, false)) {
25+
class_alias(GetResponseEvent::class, RequestListenerRequestEvent::class);
26+
}
27+
if (! class_exists(RequestListenerControllerEvent::class, false)) {
28+
class_alias(FilterControllerEvent::class, RequestListenerControllerEvent::class);
29+
}
2230
}
2331

2432
/**

0 commit comments

Comments
 (0)