From a86d64836053ebf44141f910c6602ce720c1ead0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 24 Mar 2021 15:53:49 +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 --- Rpc/Producer.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Rpc/Producer.php b/Rpc/Producer.php index 3f063080..496cecc7 100644 --- a/Rpc/Producer.php +++ b/Rpc/Producer.php @@ -90,6 +90,26 @@ class Producer extends Component } + /** + * @return array + */ + public function getService(): array + { + $array = []; + foreach (array_keys($this->cods) as $key) { + $explode = explode('.', $key); + $prefix = array_shift($explode); + + $explode = implode('.', $explode); + if (!isset($array[$prefix])) { + $array[$prefix] = []; + } + $array[$prefix][] = $explode; + } + return $array; + } + + /** * @param string $name * @return mixed