您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

如何给 controller 或 action 附加属性?

2024/3/20 5:39:26发布23次查看
在web开发过程中,有没有一种方式给 controller 或 action 附加一种属性,类似给 controller 或 action 打上不同的 tag,用于区分不同的类型,如下:
/* * @tags(all) */class usercontroller extends controller { /* * @tags(read) */ public function index() { } /* * @tags(write) */ public function add() { } /* * @tags(write) */ public function foo() { }}

回复内容: 在web开发过程中,有没有一种方式给 controller 或 action 附加一种属性,类似给 controller 或 action 打上不同的 tag,用于区分不同的类型,如下:
/* * @tags(all) */class usercontroller extends controller { /* * @tags(read) */ public function index() { } /* * @tags(write) */ public function add() { } /* * @tags(write) */ public function foo() { }}

撸 c# 不? 里面有 attribute 可以给成员进行标注。
python 也可以用装饰器来实现。
其他的就不熟了。
update: php 可以通过反射拿到注释,黑魔法……
reflectionclass::getdoccomment
faking method attributes in php?
java有annotation,问题在于你想怎么利用这些tag?
@all //也可以@tags(all)class usercontroller extends controller { @read public object index() { } @write public object add() { } @write public object foo() { }}
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product