Skip to content

Commit 9fb0446

Browse files
committed
Extend Event class from symfony/contracts
1 parent 99e856b commit 9fb0446

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/Event.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@
1111

1212
namespace FOS\HttpCache;
1313

14-
use Symfony\Component\EventDispatcher\Event as BaseEvent;
14+
use Symfony\Component\EventDispatcher\Event as BaseEventDeprecated;
15+
use Symfony\Contracts\EventDispatcher\Event as BaseEvent;
1516

16-
class Event extends BaseEvent
17+
// Symfony 4.3 BC layer
18+
if (class_exists(BaseEvent::class)) {
19+
class MiddleManEvent extends BaseEvent {}
20+
} else {
21+
class MiddleManEvent extends BaseEventDeprecated {}
22+
}
23+
24+
class Event extends MiddleManEvent
1725
{
1826
private $exception;
1927

src/SymfonyCache/CacheEvent.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@
1111

1212
namespace FOS\HttpCache\SymfonyCache;
1313

14-
use Symfony\Component\EventDispatcher\Event;
14+
use Symfony\Component\EventDispatcher\Event as EventDeprecated;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\HttpKernelInterface;
18+
use Symfony\Contracts\EventDispatcher\Event;
19+
20+
// Symfony 4.3 BC layer
21+
if (class_exists(Event::class)) {
22+
class MiddleManCacheEvent extends Event {}
23+
} else {
24+
class MiddleManCacheEvent extends EventDeprecated {}
25+
}
1826

1927
/**
2028
* Event raised by the HttpCache kernel.
2129
*
2230
* @author David Buchmann <[email protected]>
2331
*/
24-
class CacheEvent extends Event
32+
class CacheEvent extends MiddleManCacheEvent
2533
{
2634
/**
2735
* @var CacheInvalidation

0 commit comments

Comments
 (0)