From c2c081ce350ebae9dc645341f324bbcfd060578d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 8 Dec 2023 16:40:22 +0100 Subject: [PATCH] removed attached() & detached() methods (BC break) --- src/ComponentModel/Component.php | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/ComponentModel/Component.php b/src/ComponentModel/Component.php index 962e71b..2e5f6b0 100644 --- a/src/ComponentModel/Component.php +++ b/src/ComponentModel/Component.php @@ -94,11 +94,8 @@ final public function lookupPath(?string $type = null, bool $throw = true): ?str */ final public function monitor(string $type, ?callable $attached = null, ?callable $detached = null): void { - if (func_num_args() === 1) { - $class = (new \ReflectionMethod($this, 'attached'))->getDeclaringClass()->getName(); - trigger_error(__METHOD__ . "(): Methods $class::attached() and $class::detached() are deprecated, use monitor(\$type, [attached], [detached])", E_USER_DEPRECATED); - $attached = [$this, 'attached']; - $detached = [$this, 'detached']; + if (!$attached && !$detached) { + throw new Nette\InvalidStateException('At least one handler is required.'); } if ( @@ -122,26 +119,6 @@ final public function unmonitor(string $type): void } - /** - * This method will be called when the component (or component's parent) - * becomes attached to a monitored object. Do not call this method yourself. - * @deprecated use monitor($type, $attached) - */ - protected function attached(IComponent $obj): void - { - } - - - /** - * This method will be called before the component (or component's parent) - * becomes detached from a monitored object. Do not call this method yourself. - * @deprecated use monitor($type, null, $detached) - */ - protected function detached(IComponent $obj): void - { - } - - /********************* interface IComponent ****************d*g**/