Skip to content

Commit 80512a1

Browse files
committed
Extend Event class from symfony/contracts
1 parent 99e856b commit 80512a1

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

src/Event.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,21 @@
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+
{
21+
}
22+
} else {
23+
class MiddleManEvent extends BaseEventDeprecated
24+
{
25+
}
26+
}
27+
28+
class Event extends MiddleManEvent
1729
{
1830
private $exception;
1931

src/SymfonyCache/CacheEvent.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,29 @@
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+
{
24+
}
25+
} else {
26+
class MiddleManCacheEvent extends EventDeprecated
27+
{
28+
}
29+
}
1830

1931
/**
2032
* Event raised by the HttpCache kernel.
2133
*
2234
* @author David Buchmann <[email protected]>
2335
*/
24-
class CacheEvent extends Event
36+
class CacheEvent extends MiddleManCacheEvent
2537
{
2638
/**
2739
* @var CacheInvalidation

0 commit comments

Comments
 (0)