Doctrine 2 带有自定义注释的类元数据
我正在尝试使用 Doctrine2 ClassMetadatas 编写创建 Zend_Form 对象的过程,以便为我的客户端数据库应用程序生成表单更容易。
我需要在某个地方存储元素标签、描述等。使用自定义 phpdoc 标签似乎是个好主意。但似乎 ClassMetadataInfo 没有提供超出其预期的“注释”。
我想这是明智的,但我正在努力寻找一种方法让它解析整个 phpdoc 块。
我已经研究过使用 getReflectionClass() 并自己解析它,但我失去了出色的缓存。 Doctrine2 解析器确实工作得很好,但我无法理解它!
能够使用 phpdoc 简短描述作为元素标签,使用长描述作为描述对于我的表单<>模型友谊来说相当方便。
还有人思考过这个问题吗?
I am trying to code the process of creating Zend_Form objects using Doctrine2 ClassMetadatas so that form generation for my client database application is easier.
I needed somewhere to store the element labels, descriptions, and etc. using custom phpdoc tags seemed a good idea. But it seems ClassMetadataInfo doesn't provide 'annotations' outside what it's expecting.
Thats sensible I guess, but im struggling to find a way to get it to parse the entire phpdoc block.
I've looked at using getReflectionClass() and parsing it myself, but id loose out on the great caching. The Doctrine2 parser works really well for what it does, but I can't make heads or tails of it!
Being able to use the phpdoc short description as an element label, and long description as the description would be rather handy for my form<>model friendships.
Anyone else pondered on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Dotrine2 提供了 AnnotationDriver(由 ORM 使用)和 AnnotationReader(由驱动程序使用,并提供更抽象的方法)。
看一下源码
Doctrine\ORM \Mapping\Driver\AnnotationDriver
学说\Common\Annotations\AnnotationReader
Dotrine2 provides both an AnnotationDriver (which is used by the ORM) and an AnnotationReader (used by the driver and which provides more abstract method).
Take a look at the source
Doctrine\ORM\Mapping\Driver\AnnotationDriver
Doctrine\Common\Annotations\AnnotationReader
如果有人找到这个答案:到目前为止,最新版本的 Doctrine 包括一个更高级的注释阅读器,包括缓存机制(您可能需要)。查看教义文档了解一些信息很好的用法示例。
In case anyone finds this answer: The latest version of Doctrine as of now includes a more advanced annotation reader, including caching mechanisms (which you probably want). Take a look at the doctrine documentation for some nice examples of usage.