src/Synapse/User/RoleService.php
public function addRoleForUser(UserEntity $user, $role)
    {
        $roles = $user->getRoles();

        if (! in_array($role, $roles)) {
            $this->userRolePivotMapper->addRoleForUser($user->getId(), $role);

            array_push($roles, $role);

            $user->setRoles($roles);
        }
    }
public function addRoleForUser(UserEntity $user, $role)
    {
        $roles = $user->getRoles();

        if (! in_array($role, $roles)) {
            $this->userRolePivotMapper->addRoleForUser($user->getId(), $role);

            array_push($roles, $role);

            $user->setRoles($roles);
        }
    }
public function addRoleForUser ( UserEntity $ user , $ role ) { $ roles = $ user -> getRoles ( ) ; if ( ! in_array ( $ role , $ roles ) ) { $ this -> userRolePivotMapper -> addRoleForUser ( $ user -> getId ( ) , $ role ) ; array_push ( $ roles , $ role ) ; $ user -> setRoles ( $ roles ) ; } }
Add a role to a given user

@param UserEntity $user
@param string     $role name of the role to add
Add a role to a given user