From 334ec699a8d738e2d8482c7fb3a1306a330c2e74 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Mon, 7 Jun 2021 10:19:19 +0200 Subject: [PATCH] Rename cancelable events to interruptable events --- .../system/event/ICancelableEvent.class.php | 25 ------------- .../event/IInterruptableEvent.class.php | 34 ++++++++++++++++++ .../system/event/TCancelableEvent.class.php | 36 ------------------- .../event/TInterruptableEvent.class.php | 36 +++++++++++++++++++ 4 files changed, 70 insertions(+), 61 deletions(-) delete mode 100644 wcfsetup/install/files/lib/system/event/ICancelableEvent.class.php create mode 100644 wcfsetup/install/files/lib/system/event/IInterruptableEvent.class.php delete mode 100644 wcfsetup/install/files/lib/system/event/TCancelableEvent.class.php create mode 100644 wcfsetup/install/files/lib/system/event/TInterruptableEvent.class.php diff --git a/wcfsetup/install/files/lib/system/event/ICancelableEvent.class.php b/wcfsetup/install/files/lib/system/event/ICancelableEvent.class.php deleted file mode 100644 index b01acae89c..0000000000 --- a/wcfsetup/install/files/lib/system/event/ICancelableEvent.class.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @package WoltLabSuite\Core\System\Event - * @since 5.5 - */ -interface ICancelableEvent extends IEvent -{ - /** - * Cancels the event. - */ - public function cancel(): void; - - /** - * Returns whether the event is cancelled. - */ - public function isCancelled(): bool; -} diff --git a/wcfsetup/install/files/lib/system/event/IInterruptableEvent.class.php b/wcfsetup/install/files/lib/system/event/IInterruptableEvent.class.php new file mode 100644 index 0000000000..8057249edc --- /dev/null +++ b/wcfsetup/install/files/lib/system/event/IInterruptableEvent.class.php @@ -0,0 +1,34 @@ + + * @package WoltLabSuite\Core\System\Event + * @since 5.5 + */ +interface IInterruptableEvent extends IEvent +{ + /** + * Indicates that the code path that fired this event should not proceed after + * this event was handled. The caller is responsible to check the status with + * `defaultPrevented()`. + * + * All event listeners will be invoked, even if an event listener in the middle + * of the stack calls `preventDefault()`. + */ + public function preventDefault(): void; + + /** + * Returns whether preventDefault() was called. + */ + public function defaultPrevented(): bool; +} diff --git a/wcfsetup/install/files/lib/system/event/TCancelableEvent.class.php b/wcfsetup/install/files/lib/system/event/TCancelableEvent.class.php deleted file mode 100644 index 9497d562c7..0000000000 --- a/wcfsetup/install/files/lib/system/event/TCancelableEvent.class.php +++ /dev/null @@ -1,36 +0,0 @@ - - * @package WoltLabSuite\Core\System\Event - * @since 5.5 - */ -trait TCancelableEvent -{ - /** - * @var bool - */ - private $isCancelled = false; - - /** - * @see ICancelableEvent::cancel() - */ - public function cancel(): void - { - $this->isCancelled = true; - } - - /** - * @see ICancelableEvent::isCancelled() - */ - public function isCancelled(): bool - { - return $this->isCancelled; - } -} diff --git a/wcfsetup/install/files/lib/system/event/TInterruptableEvent.class.php b/wcfsetup/install/files/lib/system/event/TInterruptableEvent.class.php new file mode 100644 index 0000000000..e41b583b31 --- /dev/null +++ b/wcfsetup/install/files/lib/system/event/TInterruptableEvent.class.php @@ -0,0 +1,36 @@ + + * @package WoltLabSuite\Core\System\Event + * @since 5.5 + */ +trait TInterruptableEvent +{ + /** + * @var bool + */ + private $defaultPrevented = false; + + /** + * @see IInterruptableEvent::preventDefault() + */ + public function preventDefault(): void + { + $this->defaultPrevented = true; + } + + /** + * @see IInterruptableEvent::defaultPrevented() + */ + public function defaultPrevented(): bool + { + return $this->defaultPrevented; + } +} -- 2.20.1