src/Identity/IdentityRoleProvider.php
public function getIdentityRoles(UserInterface $user = null)
    {
        if ($user === null) {
            $user = $this->getDefaultIdentity();
            if (!$user) {
                return (array) $this->getModuleOptions()->getDefaultGuestRole();
            }
        }

        $resultSet = $this->getUserRoleLinkerMapper()->findByUser($user);

        if (count($resultSet) > 0) { // if exists in database
            $roles = array();
            foreach ($resultSet  as $userRoleLinker) {
                $roles[] = $userRoleLinker->getRoleId();
            }

            return $roles;
        } else {
            return (array) $this->getModuleOptions()->getDefaultUserRole();
        }

    }
public function getIdentityRoles(UserInterface $user = null)
    {
        if ($user === null) {
            $user = $this->getDefaultIdentity();
            if (!$user) {
                return (array) $this->getModuleOptions()->getDefaultGuestRole();
            }
        }

        $resultSet = $this->getUserRoleLinkerMapper()->findByUser($user);

        if (count($resultSet) > 0) { // if exists in database
            $roles = array();
            foreach ($resultSet  as $userRoleLinker) {
                $roles[] = $userRoleLinker->getRoleId();
            }

            return $roles;
        } else {
            return (array) $this->getModuleOptions()->getDefaultUserRole();
        }

    }
public function getIdentityRoles ( UserInterface $ user = null ) { if ( $ user === null ) { $ user = $ this -> getDefaultIdentity ( ) ; if ( ! $ user ) { return ( array ) $ this -> getModuleOptions ( ) -> getDefaultGuestRole ( ) ; } } $ resultSet = $ this -> getUserRoleLinkerMapper ( ) -> findByUser ( $ user ) ; if ( count ( $ resultSet ) > 0 ) { // if exists in database $ roles = array ( ) ; foreach ( $ resultSet as $ userRoleLinker ) { $ roles [ ] = $ userRoleLinker -> getRoleId ( ) ; } return $ roles ; } else { return ( array ) $ this -> getModuleOptions ( ) -> getDefaultUserRole ( ) ; } }
Get the list of roles of a user

@return string[]
Get the list of roles of a user