Master ALWAYS has ANY role

This commit is contained in:
bwilliams committed 2023-06-06 14:43:02 +01:00
1 parent e86ab03f06
commit 575b5d5b36
1 file changed
+5
+5
View File
@@ -53,6 +53,11 @@ class HasRoleExtension extends AbstractExtension implements GlobalsInterface
// Add Twig function for checking permissions during dynamic menu rendering
new TwigFunction('hasRole', function ($roleSlug) {
$currentUser = $this->services->currentUser;
if ($currentUser->isMaster()) {
return true;
}
return $currentUser->roles()->where('slug', $roleSlug)->count() > 0;
}),
];