use*_*165 0 roles symfony twig
我有以下模板代码。
<div class="row">
{% include 'ProductBundle:Partials:productInfo.html.twig' %}
{% include 'OrderBundle:Partials:orderInfo.html.twig' %}
{% include 'DeliveryBundle:Partials:deliveryInfo.html.twig' %}
{% include 'BillBundle:Partials:billInfo.html.twig' %}
</div>
Run Code Online (Sandbox Code Playgroud)
我想展示ROLE_USER. 他无法访问其他三个包括。其他用户ROLE_ADMIN可以访问所有四个包含部分。
有没有办法用树枝做到这一点?
<div class="row">
{% include 'ProductBundle:Partials:productInfo.html.twig' %}
{% if is_granted('ROLE_ADMIN') -%}
{% include 'OrderBundle:Partials:orderInfo.html.twig' %}
{% include 'DeliveryBundle:Partials:deliveryInfo.html.twig' %}
{% include 'BillBundle:Partials:billInfo.html.twig' %}
{% endif %}
</div>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
199 次 |
| 最近记录: |