daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest May 16th, 2018 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. namespace AppBundle\Controller;
  4.  
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  7. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  8.  
  9. /**
  10.  * Class SheetController
  11.  * @package AppBundle\Controller
  12.  *
  13.  * @Route("/sheet")
  14.  */
  15. class SheetController extends AppController
  16. {
  17.     /**
  18.      * @Route("/create", name="create_sheet")
  19.      * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
  20.      */
  21.     public function createAction(Request $request)
  22.     {
  23.         $securityService = $this->get('app_security');
  24.  
  25.         if (!$securityService->isUserAuthenticated()) {
  26.             return $this->redirect(
  27.                 $securityService->buildDeniedAccessUrl()
  28.             );
  29.         }
  30.  
  31.         $createdSheetID = $this->getRepository('AppBundle:Sheet')->createSheet(
  32.             $this->getUser()
  33.         );
  34.  
  35.         return $this->redirectToRoute('view_sheet', [
  36.             'id' => $createdSheetID
  37.         ]);
  38.     }
  39.  
  40.     /**
  41.      * @Route("/view/{id}", name="view_sheet")
  42.      * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
  43.      */
  44.     public function viewAction(Request $request, $id = null)
  45.     {
  46.         $sheetService = $this->get('app_sheet');
  47.  
  48.         if (!$sheetService->isValidId($id)) {
  49.             $this->redirectToRoute('homepage');
  50.         }
  51.  
  52.         $sheet = $this->getRepository('AppBundle:Sheet')->find($id);
  53.  
  54.         return $this->render('sheet.html.twig', [
  55.             'sheet' => $sheet
  56.         ]);
  57.     }
  58.  
  59.     /**
  60.      * @Route("/share/{id}", name="share_sheet")
  61.      * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
  62.      */
  63.     public function shareAction(Request $request, $id = null)
  64.     {
  65.         $sheetService = $this->get('app_sheet');
  66.  
  67.         if (!$sheetService->isValidId($id)) {
  68.             $this->redirectToRoute('homepage');
  69.         }
  70.  
  71.         $this->getRepository('AppBundle:Sheet')->shareSheet($id);
  72.  
  73.         return $this->redirectToRoute('dashboard');
  74.     }
  75.  
  76.     /**
  77.      * @Route("/delete/{id}", name="remove_sheet")
  78.      * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
  79.      */
  80.     public function deleteAction(Request $request, $id = null)
  81.     {
  82.         $sheetService = $this->get('app_sheet');
  83.  
  84.         if (!$sheetService->isValidId($id)) {
  85.             $this->redirectToRoute('homepage');
  86.         }
  87.  
  88.         $this->getRepository('AppBundle:Sheet')->removeSheet($id);
  89.  
  90.         return $this->redirectToRoute('dashboard');
  91.     }
  92. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top