【发布时间】:2014-07-03 05:16:54
【问题描述】:
当用户未使用自定义注释登录时,我似乎无法确定是否可以保护Controller's Action。
这就是我想要实现的目标:
...
class FooController extends Controller
{
...
/*
* The code bellow should only be executed if the user
* is authorized, otherwise should throw an exception
* or something.
*
* @Authorized
*/
public function barAction($cid) {
// do stuff only if user is authorized
}
...
}
我知道我可以使用某种“装饰器设计模式”来做到这一点,但我真正想要的是更像 Python 的 装饰器 使用 PHP 注解
这可能吗?我该怎么做?
【问题讨论】:
标签: php python symfony annotations decorator