Every Group is connected with the ROLE_USER
role by default.
Adding Roles is quite simple. Add this to your config/config.yaml
:
security:
role_hierarchy:
ROLE_MEMBERS_MODERATOR: [ROLE_USER]
Open your group object, select ROLE_MEMBERS_MODERATOR
and save group.
Note: Make sure that your user is connected with this group.
Check the Role in a controller
<?php
class RoleController {
public function checkAction(Request $request)
{
$this->denyAccessUnlessGranted('ROLE_MEMBERS_MODERATOR', null, 'Unable to access this page!');
}
}