From 62f709868e4f5394fc5984b0405e9278353905ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 20 Aug 2021 14:36:50 +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 --- Kafka/Annotation/Kafka.php | 38 +++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/Kafka/Annotation/Kafka.php b/Kafka/Annotation/Kafka.php index 29177de3..428578f9 100644 --- a/Kafka/Annotation/Kafka.php +++ b/Kafka/Annotation/Kafka.php @@ -18,13 +18,13 @@ use Kiri\Kiri; { - /** - * Kafka constructor. - * @param string $topic - */ - public function __construct(public string $topic) - { - } + /** + * Kafka constructor. + * @param string $topic + */ + public function __construct(public string $topic) + { + } /** @@ -33,21 +33,17 @@ use Kiri\Kiri; * @return bool * @throws Exception */ - public function execute(mixed $class, mixed $method = null): bool - { - if (!($class instanceof ConsumerInterface)) { - return false; - } + public function execute(mixed $class, mixed $method = null): bool + { + if (!in_array(ConsumerInterface::class, class_implements($class))) { + return false; + } + /** @var KafkaProvider $container */ + $container = Kiri::getDi()->get(KafkaProvider::class); + $container->addConsumer($this->topic, $class); - - var_dump($class); - - /** @var KafkaProvider $container */ - $container = Kiri::getDi()->get(KafkaProvider::class); - $container->addConsumer($this->topic, $class); - - return true; - } + return true; + } }