小编Jon*_*han的帖子

symfony2:twig扩展名is_granted('EDIT',comment)在foreach循环中不起作用

官方ACL示例的代码有效:http://symfony.com/doc/current/cookbook/security/acl.html

如果我这样做,没问题......

{% if is_granted('EDIT', comment) %}
    Edit
{% endif %}
Run Code Online (Sandbox Code Playgroud)

...但如果我想要一个关联对象的"授予访问权限",它就不起作用.

{% for comment in news.comments %}
    comment.content
    {% if is_granted('EDIT', comment) %}
        Edit
    {% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

我认为枝条扩展不能知道"评论"是"评论实体".

查询搜索"Proxies\JblNewsBundleEntityCommentProxy"而不是"Jbl\NewsBundle\Entity\Comment":

SELECT a.ancestor_id FROM acl_object_identities o INNER JOIN acl_classes c ON c.id = o.class_id INNER JOIN acl_object_identity_ancestors a ON a.object_identity_id = o.id WHERE ((o.object_identifier = '38' AND c.class_type = 'Proxies\\JblNewsBundleEntityCommentProxy'))
Run Code Online (Sandbox Code Playgroud)

但我不知道如何解决这个问题.

请问有解决方案吗?

acl symfony twig

5
推荐指数
1
解决办法
5178
查看次数

标签 统计

acl ×1

symfony ×1

twig ×1