-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Añadidos cambios para la segunda sesión... Controladores, Anotaciones…
… y Seguridad
- Loading branch information
Showing
7 changed files
with
331 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Esta es la carta número {{ cardNumber }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
|
||
namespace AppBundle\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; | ||
use JMS\DiExtraBundle\Annotation\Inject; | ||
|
||
/** | ||
* @Route("/panel") | ||
*/ | ||
class PanelController extends Controller | ||
{ | ||
/** | ||
* @Inject("request", strict = false) | ||
*/ | ||
private $request; | ||
|
||
/** | ||
* @Route("/", name="panel_dashboard") | ||
*/ | ||
public function dashboardAction() | ||
{ | ||
$url = $this->generateUrl('panel_previewCard', array('card' => '1')); | ||
|
||
var_dump($url); | ||
|
||
return new RedirectResponse($url); | ||
|
||
// También se podría hacer la redirección a URL directamente | ||
// return $this->redirect($url); | ||
|
||
// También se podría devolver un String | ||
// return new Response("dashboard"); | ||
// return $this->render('dashboard.html.twig'); | ||
} | ||
|
||
/** | ||
* @Route("/preferences", name="panel_preferences") | ||
*/ | ||
public function preferencesAction() | ||
{ | ||
$mailer = $this->get('mailer'); | ||
var_dump($mailer); | ||
|
||
var_dump($this->container->getParameter('locale')); | ||
|
||
return new Response("preferences"); | ||
} | ||
|
||
/** | ||
* @Route("/previewCard/{card}", name="panel_previewCard") | ||
* @Method("GET") | ||
* @return Response | ||
*/ | ||
public function previewCardAction($card) | ||
{ | ||
var_dump($this->request->query->all()); | ||
|
||
if ($card == 0 || $card == null) { | ||
throw $this->createNotFoundException('The product does not exist'); | ||
|
||
// También se podría devolver un String y el código HTTP 404 | ||
// return new Response("notFound", Response::HTTP_NOT_FOUND); | ||
} | ||
|
||
return $this->render('previewCard.html.twig', array( | ||
'cardNumber' => $card | ||
)); | ||
|
||
// También se podría devolver un JSON | ||
// return new JsonResponse(array('cardNumber' => $card)); | ||
|
||
// También se podría devolver simplemente un String | ||
// return new Response("previewCard - ".$card); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace AppBundle\Controller; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\Routing\Annotation\Route; | ||
|
||
class PublicController extends Controller | ||
{ | ||
/** | ||
* @Route("/", name="public_landing") | ||
*/ | ||
public function landingAction() | ||
{ | ||
return new Response("Landing"); | ||
// return $this->render('landing.html.twig'); | ||
} | ||
} |