src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php
public function setRoles(array $roles)
    {
        $this->roles->clear();
        foreach ($roles as $role) {
            $this->addRole($role);
        }

        return $this;
    }
public function setRoles(array $roles)
    {
        $this->roles->clear();
        foreach ($roles as $role) {
            $this->addRole($role);
        }

        return $this;
    }
public function setRoles ( array $ roles ) { $ this -> roles -> clear ( ) ; foreach ( $ roles as $ role ) { $ this -> addRole ( $ role ) ; } return $ this ; }
Pass an ARRAY of Role objects and will clear the collection and re-set it with new Roles.

@param Role[] $roles array of Role objects

@return GroupInterface
Pass an ARRAY of Role objects and will clear the collection and re - set it with new Roles .