public function getEntityRoles($areGroupsIncluded = true)
    {
        $roles = [];
        if ($this->roles) {
            $roles = $this->roles->toArray();
        }

        if ($areGroupsIncluded) {
            foreach ($this->groups as $group) {
                foreach ($group->getEntityRoles() as $role) {
                    if (!in_array($role, $roles)) {
                        $roles[] = $role;
                    }
                }
            }
        }

        return $roles;
    }
public function getEntityRoles($areGroupsIncluded = true)
    {
        $roles = [];
        if ($this->roles) {
            $roles = $this->roles->toArray();
        }

        if ($areGroupsIncluded) {
            foreach ($this->groups as $group) {
                foreach ($group->getEntityRoles() as $role) {
                    if (!in_array($role, $roles)) {
                        $roles[] = $role;
                    }
                }
            }
        }

        return $roles;
    }
public function getEntityRoles ( $ areGroupsIncluded = true ) { $ roles = [ ] ; if ( $ this -> roles ) { $ roles = $ this -> roles -> toArray ( ) ; } if ( $ areGroupsIncluded ) { foreach ( $ this -> groups as $ group ) { foreach ( $ group -> getEntityRoles ( ) as $ role ) { if ( ! in_array ( $ role , $ roles ) ) { $ roles [ ] = $ role ; } } } } return $ roles ; }
Returns the user's roles as an array of entities. The roles
owned by groups the user is a member are included by default.

@param bool $areGroupsIncluded

@return Role[]
Returns the user s roles as an array of entities . The roles owned by groups the user is a member are included by default .