From fd95b181999c7e5c9d4c5812be8865c4c7907a8f Mon Sep 17 00:00:00 2001 From: Piddubnij <3581350+piddubnij@users.noreply.github.com> Date: Tue, 3 Jan 2023 13:52:07 +0200 Subject: [PATCH] add deprecation notice not setting the "admin_code" --- src/Twig/RolesMatrixExtension.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Twig/RolesMatrixExtension.php b/src/Twig/RolesMatrixExtension.php index 1f953da78..9b3eb3789 100644 --- a/src/Twig/RolesMatrixExtension.php +++ b/src/Twig/RolesMatrixExtension.php @@ -72,7 +72,19 @@ public function renderMatrix(Environment $environment, FormView $form): string $groupedRoles = []; foreach ($this->rolesBuilder->getRoles() as $role => $attributes) { if (!isset($attributes['admin_code'])) { - continue; + // NEXT_MAJOR: Remove those lines and uncomment the last one. + @trigger_error( + 'Not setting the "admin_code" attribute to admin role is deprecated since sonata-project/user-bundle 5.5' + .' and without it admin role will be skipped in version 6.0.', + \E_USER_DEPRECATED + ); + + if (!isset($attributes['admin_label'])) { + continue; + } + + $attributes['admin_code'] = $attributes['admin_label']; + // continue; } $groupCode = $attributes['group_code'] ?? '';