5
官方ACL例子的代碼工作:http://symfony.com/doc/current/cookbook/security/acl.html的Symfony2:樹枝延伸is_granted(「編輯」,評論)不會在foreach循環工作
如果我這樣做,沒有問題... ...
{% if is_granted('EDIT', comment) %}
Edit
{% endif %}
...但如果我想要一個「授予訪問權」的關聯對象,它不起作用。
{% for comment in news.comments %}
comment.content
{% if is_granted('EDIT', comment) %}
Edit
{% endif %}
{% endfor %}
我認爲樹枝延伸不能知道「評論」是一個「評論實體」。
查詢搜索 「代理\ JblNewsBundleEntityCommentProxy」,而不是 「JBL \ NewsBundle \實體\評論」:
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'))
但我不知道如何解決這個問題。
您有解決方法嗎?