public function deleteSession(Request $request, $id)
    {
        $session = $this->getSessionRepository()->find($id);

        if (null === $session) {
            $this->app->abort(404, 'Unknown session');
        }

        if (null === $session->getUser()) {
            $this->app->abort(403, 'Unauthorized');
        }

        if ($session->getUser()->getId() !== $this->getAuthenticatedUser()->getId()) {
            $this->app->abort(403, 'Unauthorized');
        }

        $manager = $this->getEntityManager();
        $manager->remove($session);
        $manager->flush();

        if ($request->isXmlHttpRequest()) {
            return $this->app->json([
                'success' => true,
                'session_id' => $id
            ]);
        }

        return $this->app->redirectPath('account_sessions');
    }
public function deleteSession(Request $request, $id)
    {
        $session = $this->getSessionRepository()->find($id);

        if (null === $session) {
            $this->app->abort(404, 'Unknown session');
        }

        if (null === $session->getUser()) {
            $this->app->abort(403, 'Unauthorized');
        }

        if ($session->getUser()->getId() !== $this->getAuthenticatedUser()->getId()) {
            $this->app->abort(403, 'Unauthorized');
        }

        $manager = $this->getEntityManager();
        $manager->remove($session);
        $manager->flush();

        if ($request->isXmlHttpRequest()) {
            return $this->app->json([
                'success' => true,
                'session_id' => $id
            ]);
        }

        return $this->app->redirectPath('account_sessions');
    }
public function deleteSession ( Request $ request , $ id ) { $ session = $ this -> getSessionRepository ( ) -> find ( $ id ) ; if ( null === $ session ) { $ this -> app -> abort ( 404 , 'Unknown session' ) ; } if ( null === $ session -> getUser ( ) ) { $ this -> app -> abort ( 403 , 'Unauthorized' ) ; } if ( $ session -> getUser ( ) -> getId ( ) !== $ this -> getAuthenticatedUser ( ) -> getId ( ) ) { $ this -> app -> abort ( 403 , 'Unauthorized' ) ; } $ manager = $ this -> getEntityManager ( ) ; $ manager -> remove ( $ session ) ; $ manager -> flush ( ) ; if ( $ request -> isXmlHttpRequest ( ) ) { return $ this -> app -> json ( [ 'success' => true , 'session_id' => $ id ] ) ; } return $ this -> app -> redirectPath ( 'account_sessions' ) ; }
Deletes identified session

@param Request $request
@param integer $id
@return JsonResponse|RedirectResponse
Deletes identified session