【问题标题】:symfony2 : twig extension is_granted('EDIT', comment) doesn't work in a foreach loopsymfony2:树枝扩展 is_granted('EDIT', comment) 在 foreach 循环中不起作用
【发布时间】:2012-12-08 05:24:36
【问题描述】:

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

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

{% if is_granted('EDIT', comment) %}
    Edit
{% endif %}

...但是如果我想要对关联对象的“授予访问权限”,它就行不通了。

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

我认为树枝扩展无法知道“评论”是“评论实体”。

查询搜索“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'))

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

请问你有解决办法吗?

【问题讨论】:

    标签: symfony acl twig


    【解决方案1】:

    在 symfony 2.1 中已修复。

    对于旧的 2.0 版本,修复方法在这里:

    Overriding the ObjectIdentityRetrievalStrategy to check if a domain object is a Doctrine proxy

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多