Example #1
0
 /**
  * Locks or unlocks the given user
  * 
  * @Route("/users/{id}/lock")
  * @Method({"PUT","POST"})
  * @Security("has_role('ROLE_SUPER_ADMIN')")
  * @ApiDoc(
  *     requirements={
  *         {"name"="id", "description"="The ID of the user to lock", "dataType"="integer", "requirement"="\d+"}
  *     },
  *     tags={
  *         "Super Admin" = "#ff1919"
  *     }
  * )
  */
 public function toggleLockUser(User $user)
 {
     if ($user->getId() === $this->getUser()->getId()) {
         throw new AccessDeniedHttpException("You may not toggle locks on yourself.");
     }
     $user->setLocked(!$user->isLocked());
     $this->_em->flush();
     return new JsonResponse($user);
 }