src/Sulu/Bundle/SecurityBundle/Controller/GroupController.php
private function addRole(Group $group, $roleData)
    {
        if (isset($roleData['id'])) {
            $role = $this->get('sulu.repository.role')->findRoleById($roleData['id']);

            if (!$role) {
                throw new EntityNotFoundException($this->get('sulu.repository.role')->getClassName(), $roleData['id']);
            }

            if (!$group->getRoles()->contains($role)) {
                $group->addRole($role);
            }
        }

        return true;
    }
private function addRole(Group $group, $roleData)
    {
        if (isset($roleData['id'])) {
            $role = $this->get('sulu.repository.role')->findRoleById($roleData['id']);

            if (!$role) {
                throw new EntityNotFoundException($this->get('sulu.repository.role')->getClassName(), $roleData['id']);
            }

            if (!$group->getRoles()->contains($role)) {
                $group->addRole($role);
            }
        }

        return true;
    }
private function addRole ( Group $ group , $ roleData ) { if ( isset ( $ roleData [ 'id' ] ) ) { $ role = $ this -> get ( 'sulu.repository.role' ) -> findRoleById ( $ roleData [ 'id' ] ) ; if ( ! $ role ) { throw new EntityNotFoundException ( $ this -> get ( 'sulu.repository.role' ) -> getClassName ( ) , $ roleData [ 'id' ] ) ; } if ( ! $ group -> getRoles ( ) -> contains ( $ role ) ) { $ group -> addRole ( $ role ) ; } } return true ; }
Adds the given role to the group.

@param Group $group
@param array $roleData

@return bool

@throws \Sulu\Component\Rest\Exception\EntityNotFoundException
Adds the given role to the group .