Solution for handling Event errors on upgrade

Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
Andy Miller
2025-10-20 11:30:44 -06:00
parent e110701079
commit 0d2d0bdc11

View File

@@ -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;