UserBundle/Entity/User.php
public function getRoles()
    {
        $roles = $this->roles;

        foreach ($this->getGroups() as $group) {
            /** @noinspection SlowArrayOperationsInLoopInspection */
            $roles = array_merge($roles, $group->getRoles());
        }

        // we need to make sure to have at least one role
        $roles[] = static::ROLE_DEFAULT;

        return array_unique($roles);
    }
public function getRoles()
    {
        $roles = $this->roles;

        foreach ($this->getGroups() as $group) {
            /** @noinspection SlowArrayOperationsInLoopInspection */
            $roles = array_merge($roles, $group->getRoles());
        }

        // we need to make sure to have at least one role
        $roles[] = static::ROLE_DEFAULT;

        return array_unique($roles);
    }
public function getRoles ( ) { $ roles = $ this -> roles ; foreach ( $ this -> getGroups ( ) as $ group ) { /** @noinspection SlowArrayOperationsInLoopInspection */ $ roles = array_merge ( $ roles , $ group -> getRoles ( ) ) ; } // we need to make sure to have at least one role $ roles [ ] = static :: ROLE_DEFAULT ; return array_unique ( $ roles ) ; }
Returns the user roles.

@return array The roles
Returns the user roles .