You are here

public function LearningPathMembershipController::deleteUser in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/Controller/LearningPathMembershipController.php \Drupal\opigno_learning_path\Controller\LearningPathMembershipController::deleteUser()

Ajax callback used in opigno_learning_path_member_overview.js.

Removes member from learning path.

Return value

\Symfony\Component\HttpFoundation\JsonResponse Response.

1 string reference to 'LearningPathMembershipController::deleteUser'
opigno_learning_path.routing.yml in ./opigno_learning_path.routing.yml
opigno_learning_path.routing.yml

File

src/Controller/LearningPathMembershipController.php, line 410

Class

LearningPathMembershipController
Controller for the actions related to LP membership.

Namespace

Drupal\opigno_learning_path\Controller

Code

public function deleteUser() {

  /** @var \Drupal\group\Entity\Group $group */
  $group = \Drupal::routeMatch()
    ->getParameter('group');
  if (!isset($group)) {
    throw new NotFoundHttpException();
  }
  $uid = \Drupal::request()->query
    ->get('user_id');
  $user = User::load($uid);
  if (!isset($user)) {
    throw new NotFoundHttpException();
  }
  $member = $group
    ->getMember($user);
  if (!isset($member)) {
    throw new NotFoundHttpException();
  }
  $group
    ->removeMember($user);
  return new JsonResponse();
}