1

I have implemented BjyAuthorize with ZfcUser and Doctrine and can successfully set up the roles and linked them to user_id in the user_role_linker table. Next I want to add a simple admin panel to get, add and remove users from the user_role_linker table.

I can see certain methods available based on the currently logged in identity e.g. getIdentityRoles() but how is it possible to get /add / remove roles for any user?

This is clearly possible with MySQL direct to the table but presumably it's achievable by a BjyAuthorize service?

1 Answers1

0

I've figured this out - to add a role the just use the $user->addRole() method in the zfcUser entity provided by bjyAuthorize:

$addRole = //id of role to add
$roleRepo = $em->getRepository('Application\Entity\Role');
$roleResult = $roleRepo->findOneBy(['id' => $addRole]);
$user->addRole($roleResult);

This works fine, but I can't see how it is possible to delete a role?