From 76fc7adc01375b4a0ecb7ba35443cd8cd27a3432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Tue, 11 Feb 2020 13:10:56 +0800 Subject: [PATCH 1/3] Added event `AfterExecute`. --- src/command/src/Command.php | 2 ++ src/command/src/Event/AfterExecute.php | 17 ++++++++++ .../src/Listener/ClearTimerListener.php | 32 +++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 src/command/src/Event/AfterExecute.php create mode 100644 src/command/src/Listener/ClearTimerListener.php diff --git a/src/command/src/Command.php b/src/command/src/Command.php index f2837c57b4..07df086928 100644 --- a/src/command/src/Command.php +++ b/src/command/src/Command.php @@ -399,6 +399,8 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->eventDispatcher->dispatch(new Event\FailToHandle($this, $exception)); return $exception->getCode(); + } finally { + $this->eventDispatcher->dispatch(new Event\AfterExecute($this)); } return 0; diff --git a/src/command/src/Event/AfterExecute.php b/src/command/src/Event/AfterExecute.php new file mode 100644 index 0000000000..90ce475030 --- /dev/null +++ b/src/command/src/Event/AfterExecute.php @@ -0,0 +1,17 @@ + Date: Tue, 11 Feb 2020 13:14:31 +0800 Subject: [PATCH 2/3] Update Command.php --- src/command/src/Command.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/command/src/Command.php b/src/command/src/Command.php index 07df086928..38d178c75b 100644 --- a/src/command/src/Command.php +++ b/src/command/src/Command.php @@ -400,7 +400,7 @@ protected function execute(InputInterface $input, OutputInterface $output) $this->eventDispatcher->dispatch(new Event\FailToHandle($this, $exception)); return $exception->getCode(); } finally { - $this->eventDispatcher->dispatch(new Event\AfterExecute($this)); + $this->eventDispatcher && $this->eventDispatcher->dispatch(new Event\AfterExecute($this)); } return 0; From 6fbe553f851d49d294705deeb943de66ce8541da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=93=AD=E6=98=95?= <715557344@qq.com> Date: Wed, 12 Feb 2020 09:29:44 +0800 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d40e717534..5e9f93a056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#1328](https://github.com/hyperf/hyperf/pull/1328) Added `ModelRewriteInheritanceVisitor` to rewrite the model inheritance for command `gen:model`. - [#1331](https://github.com/hyperf/hyperf/pull/1331) Added `Hyperf\LoadBalancer\LoadBalancerInterface::getNodes()`. +- [#1335](https://github.com/hyperf/hyperf/pull/1335) Added event `AfterExecute` for `command`. ## Changed