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 diff --git a/src/command/src/Command.php b/src/command/src/Command.php index f2837c57b4..38d178c75b 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 && $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 @@ +