如何在 Symfony2 中同时创建限制区域和非限制区域
我必须构建的是一些页面受限制的页面,一些页面不在类似的链接上。我将尝试通过示例进行解释:
假设我的系统中有用户(基于 FOSUserBundle),并且每个用户都有自己的帐户,其中包含博客和图库(不同的控制器)。一些用户希望仅允许某些人(未存储在系统中)访问他们的博客和画廊,因此他们生成令牌(只有一个令牌,因此任何知道令牌的人都可以访问该区域)并发送到用户。我不想做的是在控制器的每个方法中检查它。
假设我们有 2 位用户,steven 和 stan,其中第一个用户希望他的博客和画廊免费可见,但第二个用户希望受到限制在令牌上。
链接将是这样的:
/steven/blog
/steven/gallery
/stan/blog
/stan/gallery
有人可以推荐一些解决方案或者知道我如何尝试在 Symfony2 中构建它吗?
what i have to build is page that have some pages that are restricted and some are not on similar links. I`ll try to explain it on example:
Let's say that i have users in my system (based on FOSUserBundle), and each of them have own account that contains a Blog and Gallery (different controllers). Some of User want to give access to thier Blog and Gallery only for certain group of people (that are not stored in system), so they generate token (only one token, so whoever know token will be able to access area) and sends to Users. What i don`t want to do is to check it in each method of controllers.
So let`s say we have 2 users, steven and stan and first of them want to make his blog and gallery free to see, but second one want to be restricted based on token.
Link would be like this:
/steven/blog
/steven/gallery
/stan/blog
/stan/gallery
Could anybody recommend some solution or any idea how can i try to build it in Symfony2?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您为什么不想将其签入控制器?我没有看到任何其他方法可以做到这一点,根据您希望它是动态的并且可能会变化。
Why don't you want to check it into the controllers ? I don't see any others ways to do that, according you want it to be dynamic and possibly changing.