You are here

public function MoxtraService::removeUserFromWorkspace in Opigno Moxtra 8

Same name and namespace in other branches
  1. 3.x src/MoxtraService.php \Drupal\opigno_moxtra\MoxtraService::removeUserFromWorkspace()

Removes users from the workspace.

Parameters

int $owner_id: User ID.

string $binder_id: Binder ID.

int $user_id: ID of the user to remove from the workspace.

Return value

array Response data.

Overrides MoxtraServiceInterface::removeUserFromWorkspace

File

src/MoxtraService.php, line 461

Class

MoxtraService
Implements Moxtra REST API.

Namespace

Drupal\opigno_moxtra

Code

public function removeUserFromWorkspace($owner_id, $binder_id, $user_id) {
  $data = [
    'unique_id' => $user_id,
    'suppress_feed' => TRUE,
  ];
  $url = $this
    ->getRemoveUserUrl($owner_id, $binder_id);
  $response = $this->moxtraConnector
    ->request($url, $data);
  if (!empty($response) && $response['http_code'] == 200) {
    $owner = User::load($owner_id);

    /** @var \Drupal\user\Entity\User $user */
    $user = User::load($user_id);
    $message = $this
      ->t('@owner removed @user from this conversation.', [
      '@owner' => $owner
        ->getDisplayName(),
      '@user' => $user
        ->getDisplayName(),
    ]);
    $this
      ->sendMessage($owner_id, $binder_id, $message);
  }
  return $response;
}