Skip to content

Extend Event class from symfony/contracts #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
### General

* Use `LegacyEventDispatcherProxy` for Symfony >= 4.3 to avoid deprecation messages.
* Event classes now extend `Symfony\Contracts\EventDispatcher\Event` if available.

2.7.0
-----
Expand Down
16 changes: 14 additions & 2 deletions src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,21 @@

namespace FOS\HttpCache;

use Symfony\Component\EventDispatcher\Event as BaseEvent;
use Symfony\Component\EventDispatcher\Event as BaseEventDeprecated;
use Symfony\Contracts\EventDispatcher\Event as BaseEvent;

class Event extends BaseEvent
// Symfony 4.3 BC layer
if (class_exists(BaseEvent::class)) {
class MiddleManEvent extends BaseEvent
{
}
} else {
class MiddleManEvent extends BaseEventDeprecated
{
}
}

class Event extends MiddleManEvent
{
private $exception;

Expand Down
16 changes: 14 additions & 2 deletions src/SymfonyCache/CacheEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,29 @@

namespace FOS\HttpCache\SymfonyCache;

use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\Event as EventDeprecated;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Contracts\EventDispatcher\Event;

// Symfony 4.3 BC layer
if (class_exists(Event::class)) {
class MiddleManCacheEvent extends Event
{
}
} else {
class MiddleManCacheEvent extends EventDeprecated
{
}
}

/**
* Event raised by the HttpCache kernel.
*
* @author David Buchmann <[email protected]>
*/
class CacheEvent extends Event
class CacheEvent extends MiddleManCacheEvent
{
/**
* @var CacheInvalidation
Expand Down