Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace AppBundle\Controller;
- use Symfony\Component\HttpFoundation\Request;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
- use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
- /**
- * Class SheetController
- * @package AppBundle\Controller
- *
- * @Route("/sheet")
- */
- class SheetController extends AppController
- {
- /**
- * @Route("/create", name="create_sheet")
- * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
- */
- public function createAction(Request $request)
- {
- $securityService = $this->get('app_security');
- if (!$securityService->isUserAuthenticated()) {
- return $this->redirect(
- $securityService->buildDeniedAccessUrl()
- );
- }
- $createdSheetID = $this->getRepository('AppBundle:Sheet')->createSheet(
- $this->getUser()
- );
- return $this->redirectToRoute('view_sheet', [
- 'id' => $createdSheetID
- ]);
- }
- /**
- * @Route("/view/{id}", name="view_sheet")
- * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
- */
- public function viewAction(Request $request, $id = null)
- {
- $sheetService = $this->get('app_sheet');
- if (!$sheetService->isValidId($id)) {
- $this->redirectToRoute('homepage');
- }
- $sheet = $this->getRepository('AppBundle:Sheet')->find($id);
- return $this->render('sheet.html.twig', [
- 'sheet' => $sheet
- ]);
- }
- /**
- * @Route("/share/{id}", name="share_sheet")
- * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
- */
- public function shareAction(Request $request, $id = null)
- {
- $sheetService = $this->get('app_sheet');
- if (!$sheetService->isValidId($id)) {
- $this->redirectToRoute('homepage');
- }
- $this->getRepository('AppBundle:Sheet')->shareSheet($id);
- return $this->redirectToRoute('dashboard');
- }
- /**
- * @Route("/delete/{id}", name="remove_sheet")
- * @Security("is_granted('IS_AUTHENTICATED_FULLY')")
- */
- public function deleteAction(Request $request, $id = null)
- {
- $sheetService = $this->get('app_sheet');
- if (!$sheetService->isValidId($id)) {
- $this->redirectToRoute('homepage');
- }
- $this->getRepository('AppBundle:Sheet')->removeSheet($id);
- return $this->redirectToRoute('dashboard');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement