Skip to content

Commit

Permalink
Añadidos cambios para la segunda sesión... Controladores, Anotaciones…
Browse files Browse the repository at this point in the history
… y Seguridad
  • Loading branch information
hidabe committed Apr 15, 2017
1 parent dbf1856 commit 212dfc7
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 19 deletions.
2 changes: 2 additions & 0 deletions app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public function registerBundles()
new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\AopBundle\JMSAopBundle(),
new \AppBundle\AppBundle()
);

Expand Down
1 change: 1 addition & 0 deletions app/Resources/views/previewCard.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Esta es la carta número {{ cardNumber }}
21 changes: 5 additions & 16 deletions app/config/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,14 @@ security:
admin: { password: adminpass, roles: [ 'ROLE_ADMIN' ] }

firewalls:
default:
anonymous: ~
http_basic: ~

dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false

login:
pattern: ^/demo/secured/login$
security: false

secured_area:
pattern: ^/demo/secured/
form_login:
check_path: _security_check
login_path: _demo_login
logout:
path: _demo_logout
target: _demo
#anonymous: ~
#http_basic:
# realm: "Secured Demo Area"

access_control:
- { path: /panel, roles: ROLE_USER }
#- { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY, requires_channel: https }
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~3.0",
"sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0"
"incenteev/composer-parameter-handler": "~2.0",
"jms/di-extra-bundle": "^1.8"
},
"scripts": {
"post-install-cmd": [
Expand Down
222 changes: 220 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions src/AppBundle/Controller/PanelController.php
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);
}
}
19 changes: 19 additions & 0 deletions src/AppBundle/Controller/PublicController.php
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');
}
}

0 comments on commit 212dfc7

Please sign in to comment.