BjyAuthorize modifies the User entity and provides an addRole() method. This accepts a role object and populates the user_role_linker_table
How is it possible to remove a role once it is added to a user?
The associations are set in User:
/**
* @var \Doctrine\Common\Collections\Collection
* @ORM\ManyToMany(targetEntity="Application\Entity\Role")
* @ORM\JoinTable(name="user_role_linker",
* joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="role_id", referencedColumnName="id")}
* )
*/
protected $roles;
After hours of struggle I came up with the following solution:
In the User entity I added the method:
Not sure if this is the approach that the authors of BjyAuthorize intended but it works for me...