Skip to content

Commit 0f992ac

Browse files
committed
cleanup: use roles constants
1 parent 4d220a0 commit 0f992ac

File tree

4 files changed

+4
-11
lines changed

4 files changed

+4
-11
lines changed

config/packages/security.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ security:
7171

7272
# The ROLE_ADMIN role inherits from the ROLE_USER role
7373
role_hierarchy:
74-
!php/const App\Entity\User::ROLE_ADMIN: !php/const App\Entity\User::ROLE_USER
74+
ROLE_ADMIN: ROLE_USER
7575

7676
when@test:
7777
# this configuration simplifies testing URLs protected by the security mechanism

config/packages/twig.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ twig:
44
- 'form/layout.html.twig'
55
- 'form/fields.html.twig'
66

7-
# The following variables are available in all Twig templates
8-
globals:
9-
# We can use PHP constants (native PHP ones or from the application) thanks
10-
# to the !php/const syntax.
11-
ROLE_USER: !php/const App\Entity\User::ROLE_USER
12-
ROLE_ADMIN: !php/const App\Entity\User::ROLE_ADMIN
13-
147
when@test:
158
twig:
169
strict_variables: true

templates/base.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
</a>
5656
</li>
5757

58-
{% if is_granted(ROLE_ADMIN) %}
58+
{% if is_granted('ROLE_ADMIN') %}
5959
<li>
6060
<a href="{{ path('admin_post_index') }}">
6161
<i class="fa fa-lock" aria-hidden="true"></i> {{ 'menu.admin'|trans }}

templates/security/login.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@
6767
<tr>
6868
<td>john_user</td>
6969
<td>kitten</td>
70-
<td><code>{{ ROLE_USER }}</code> ({{ 'help.role_user'|trans }})</td>
70+
<td><code>ROLE_USER</code> ({{ 'help.role_user'|trans }})</td>
7171
<td>
7272
<button class="btn btn-primary btn-sm" {{ stimulus_action('login', 'prefillJohnUser') }}><i class="fa fa-user"></i></button>
7373
</td>
7474
</tr>
7575
<tr>
7676
<td>jane_admin</td>
7777
<td>kitten</td>
78-
<td><code>{{ ROLE_ADMIN }}</code> ({{ 'help.role_admin'|trans }})</td>
78+
<td><code>ROLE_ADMIN</code> ({{ 'help.role_admin'|trans }})</td>
7979
<td>
8080
<button class="btn btn-primary btn-sm" {{ stimulus_action('login', 'prefillJaneAdmin') }}><i class="fa fa-user"></i></button>
8181
</td>

0 commit comments

Comments
 (0)