如何执行自定义注解收集器 #5196
Unanswered
huanghantao
asked this question in
Q&A
如何执行自定义注解收集器
#5196
Replies: 1 comment
-
需要在 父类: abstract class AbstractAnnotation implements AnnotationInterface, Arrayable
{
public function collectClass(string $className): void
{
AnnotationCollector::collectClass($className, static::class, $this);
}
public function collectMethod(string $className, ?string $target): void
{
AnnotationCollector::collectMethod($className, $target, static::class, $this);
}
public function collectProperty(string $className, ?string $target): void
{
AnnotationCollector::collectProperty($className, $target, static::class, $this);
}
} 将 <?php
namespace App\Infrastructure\Core\Plugin;
use Hyperf\Di\Annotation\AbstractAnnotation;
#[\Attribute]
class PluginAnnotation extends AbstractAnnotation
{
public function collectClass(string $className): void
{
PluginCollector::collectClass($className);
}
public function collectMethod(string $className, ?string $target): void
{
PluginCollector::collectMethod($className, $target);
}
public function collectProperty(string $className, ?string $target): void
{
PluginCollector::collectProperty($className, $target);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
使用的hyperf版本是v3.
我的相关目录结构如下:
首先定义了一个注解:
然后使用注解:
然后定义了一个收集器:
然后在配置文件
config/autoload/annotations.php
进行配置:启动服务,但是没有执行收集器:
Beta Was this translation helpful? Give feedback.
All reactions