public function deleteAction(Request $request)
	{
		// TODO: Add validation class to have ability check like " if (empty($validation['errors'])){} "
		if (!$request->request->get('user_id')) {
			throw new CmsException(null, 'User id is not set');
		}

		$userId = $request->request->get('user_id');

		$currentUser = $this->getUser();
		$currentUserId = $currentUser->getId();

		if ($currentUserId == $userId) {
			throw new CmsException(null, 'You can\'t delete current user account');
		}

		$user = $this->container->getDoctrine()->getRepository('CmsAuthentication:User')->findOneById($userId);

		if (empty($user)) {
			throw new CmsException(null, 'Can\'t find user with such id');
		}

//		$this->checkActionPermission($user->getGroup(), Group::PERMISSION_MODIFY_USER_NAME);

		$this->container->getDoctrine()->getManager()->remove($user);
		$this->container->getDoctrine()->getManager()->flush();

		return new SupraJsonResponse(null);
	}
public function deleteAction(Request $request)
	{
		// TODO: Add validation class to have ability check like " if (empty($validation['errors'])){} "
		if (!$request->request->get('user_id')) {
			throw new CmsException(null, 'User id is not set');
		}

		$userId = $request->request->get('user_id');

		$currentUser = $this->getUser();
		$currentUserId = $currentUser->getId();

		if ($currentUserId == $userId) {
			throw new CmsException(null, 'You can\'t delete current user account');
		}

		$user = $this->container->getDoctrine()->getRepository('CmsAuthentication:User')->findOneById($userId);

		if (empty($user)) {
			throw new CmsException(null, 'Can\'t find user with such id');
		}

//		$this->checkActionPermission($user->getGroup(), Group::PERMISSION_MODIFY_USER_NAME);

		$this->container->getDoctrine()->getManager()->remove($user);
		$this->container->getDoctrine()->getManager()->flush();

		return new SupraJsonResponse(null);
	}
public function deleteAction ( Request $ request ) { // TODO: Add validation class to have ability check like " if (empty($validation['errors'])){} " if ( ! $ request -> request -> get ( 'user_id' ) ) { throw new CmsException ( null , 'User id is not set' ) ; } $ userId = $ request -> request -> get ( 'user_id' ) ; $ currentUser = $ this -> getUser ( ) ; $ currentUserId = $ currentUser -> getId ( ) ; if ( $ currentUserId == $ userId ) { throw new CmsException ( null , 'You can\'t delete current user account' ) ; } $ user = $ this -> container -> getDoctrine ( ) -> getRepository ( 'CmsAuthentication:User' ) -> findOneById ( $ userId ) ; if ( empty ( $ user ) ) { throw new CmsException ( null , 'Can\'t find user with such id' ) ; } //		$this->checkActionPermission($user->getGroup(), Group::PERMISSION_MODIFY_USER_NAME); $ this -> container -> getDoctrine ( ) -> getManager ( ) -> remove ( $ user ) ; $ this -> container -> getDoctrine ( ) -> getManager ( ) -> flush ( ) ; return new SupraJsonResponse ( null ) ; }
Delete user action
Delete user action