Skip to content

Commit 538601d

Browse files
committed
Extend Event class from symfony/contracts
1 parent 01d87fa commit 538601d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Event.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@
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+
if (class_exists(BaseEvent::class)) {
18+
class Event extends BaseEvent {}
19+
} else {
20+
class Event extends BaseEventDeprecated {}
21+
}
22+
23+
class Event extends MiddleManEvent
1724
{
1825
private $exception;
1926

src/SymfonyCache/CacheEvent.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,24 @@
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+
if (class_exists(Event::class)) {
21+
class MiddleManEvent extends Event {}
22+
} else {
23+
class MiddleManEvent extends EventDeprecated {}
24+
}
1825

1926
/**
2027
* Event raised by the HttpCache kernel.
2128
*
2229
* @author David Buchmann <[email protected]>
2330
*/
24-
class CacheEvent extends Event
31+
class CacheEvent extends MiddleManEvent
2532
{
2633
/**
2734
* @var CacheInvalidation

0 commit comments

Comments
 (0)