Good I have that piece of code, I have the class "Users" and the class "Roles", in this fragment the getRole () method, perfectly gets the user name of the class users, at this point return 'ROLE_' strtoupper ($ this-> user-> getUsername ()); returning perfectly the ROLE_NOMBREDEUSUARIO , but I want to return the role, then I put getRol , and it does not work for me, it returns the id of the users. In the Users class I have the getRol () method
Could someone help me?
namespace AppBundle \ Entity;
use Symfony\Component\Security\Core\Role\RoleInterface;
use Symfony\Component\Security\Core\User\UserInterface;
class Roles implements RoleInterface
{
private $user;
public function __construct(UserInterface $user)
{
$this->user = $user;
}
public function getRole()
{
return 'ROLE_' . strtoupper($this->user->getUsername());
}
}