From 798343822228c9b2a3988a6aac1926bcf1a38fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 31 Mar 2021 00:58:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Annotation/LocalService.php | 49 +++++++++++++++++++++++++++++++++++++ System/Snowflake.php | 14 +++++++++++ 2 files changed, 63 insertions(+) create mode 100644 Annotation/LocalService.php diff --git a/Annotation/LocalService.php b/Annotation/LocalService.php new file mode 100644 index 00000000..3714c244 --- /dev/null +++ b/Annotation/LocalService.php @@ -0,0 +1,49 @@ + get_class($handler[0])]; + if (!empty($this->args)) { + $class = array_merge($class, $this->args); + } + + Snowflake::set($this->service, $class); + + return parent::execute($handler); // TODO: Change the autogenerated stub + } + +} diff --git a/System/Snowflake.php b/System/Snowflake.php index 484ca3dc..6cf263ba 100644 --- a/System/Snowflake.php +++ b/System/Snowflake.php @@ -56,6 +56,20 @@ class Snowflake static::$service = $service; } + + /** + * @param $alias + * @param array $array + * @return mixed + * @throws ComponentException + * @throws NotFindClassException + * @throws ReflectionException + */ + public static function set($alias, $array = []): mixed + { + return static::app()->set($alias, $array); + } + /** * @return Application|null */