mirror of
https://github.com/getgrav/grav.git
synced 2025-10-26 07:56:07 +01:00
Solution for handling Event errors on upgrade
Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
@@ -6,6 +6,42 @@ use RocketTheme\Toolbox\ArrayTraits\ArrayAccess;
|
||||
use RocketTheme\Toolbox\ArrayTraits\Constructor;
|
||||
use RocketTheme\Toolbox\ArrayTraits\Export;
|
||||
|
||||
if (!class_exists(__NAMESPACE__ . '\\BaseEvent', false)) {
|
||||
if (class_exists(\Symfony\Contracts\EventDispatcher\Event::class)) {
|
||||
/**
|
||||
* @internal Maps to the Symfony Contracts event when available.
|
||||
*/
|
||||
abstract class BaseEvent extends \Symfony\Contracts\EventDispatcher\Event
|
||||
{
|
||||
}
|
||||
} elseif (class_exists(\Symfony\Component\EventDispatcher\Event::class)) {
|
||||
/**
|
||||
* @internal Fallback for legacy Symfony Event dispatcher during upgrades.
|
||||
*/
|
||||
abstract class BaseEvent extends \Symfony\Component\EventDispatcher\Event
|
||||
{
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* @internal Minimal stop-propagation implementation used as a last resort.
|
||||
*/
|
||||
abstract class BaseEvent
|
||||
{
|
||||
private bool $propagationStopped = false;
|
||||
|
||||
public function isPropagationStopped(): bool
|
||||
{
|
||||
return $this->propagationStopped;
|
||||
}
|
||||
|
||||
public function stopPropagation(): void
|
||||
{
|
||||
$this->propagationStopped = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements Symfony Event interface.
|
||||
*
|
||||
@@ -14,7 +50,7 @@ use RocketTheme\Toolbox\ArrayTraits\Export;
|
||||
* @license MIT
|
||||
* @deprecated Event classes will be removed in the future. Use PSR-14 implementation instead.
|
||||
*/
|
||||
class Event extends \Symfony\Contracts\EventDispatcher\Event implements \ArrayAccess
|
||||
class Event extends BaseEvent implements \ArrayAccess
|
||||
{
|
||||
use ArrayAccess, Constructor, Export;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user