From 212dfc7d1e2eb69f1685fd605ece551c0ba49d6b Mon Sep 17 00:00:00 2001 From: hidabe Date: Sat, 15 Apr 2017 19:45:07 +0200 Subject: [PATCH] =?UTF-8?q?A=C3=B1adidos=20cambios=20para=20la=20segunda?= =?UTF-8?q?=20sesi=C3=B3n...=20Controladores,=20Anotaciones=20y=20Segurida?= =?UTF-8?q?d?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AppKernel.php | 2 + app/Resources/views/previewCard.html.twig | 1 + app/config/security.yml | 21 +- composer.json | 3 +- composer.lock | 222 +++++++++++++++++- src/AppBundle/Controller/PanelController.php | 82 +++++++ src/AppBundle/Controller/PublicController.php | 19 ++ 7 files changed, 331 insertions(+), 19 deletions(-) create mode 100644 app/Resources/views/previewCard.html.twig create mode 100644 src/AppBundle/Controller/PanelController.php create mode 100644 src/AppBundle/Controller/PublicController.php diff --git a/app/AppKernel.php b/app/AppKernel.php index 8526792..877a3f0 100755 --- a/app/AppKernel.php +++ b/app/AppKernel.php @@ -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() ); diff --git a/app/Resources/views/previewCard.html.twig b/app/Resources/views/previewCard.html.twig new file mode 100644 index 0000000..85198b0 --- /dev/null +++ b/app/Resources/views/previewCard.html.twig @@ -0,0 +1 @@ +Esta es la carta número {{ cardNumber }} \ No newline at end of file diff --git a/app/config/security.yml b/app/config/security.yml index 989a6d2..b4043d2 100755 --- a/app/config/security.yml +++ b/app/config/security.yml @@ -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 } diff --git a/composer.json b/composer.json index f71d919..f980c33 100755 --- a/composer.json +++ b/composer.json @@ -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": [ diff --git a/composer.lock b/composer.lock index 144a067..9638cff 100755 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "9c76b38715fafc1cd9de5a905c64f964", - "content-hash": "2ce5f7451951b83ed6674ac9718de868", + "hash": "cf57dfbc7d40dc5e48af2c75d1e944ce", + "content-hash": "062978cd773a9c2e1f76e04fdd71a658", "packages": [ { "name": "doctrine/annotations", @@ -820,6 +820,224 @@ ], "time": "2014-01-12 16:20:24" }, + { + "name": "jms/aop-bundle", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/JMSAopBundle.git", + "reference": "78000d007e74283cc564a58e184d7f62548ad394" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/JMSAopBundle/zipball/78000d007e74283cc564a58e184d7f62548ad394", + "reference": "78000d007e74283cc564a58e184d7f62548ad394", + "shasum": "" + }, + "require": { + "jms/cg": "^1.1", + "php": ">=5.3.9", + "symfony/framework-bundle": "^2.3|^3.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^2.7" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "autoload": { + "psr-4": { + "JMS\\AopBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Adds AOP capabilities to Symfony2", + "keywords": [ + "annotations", + "aop" + ], + "time": "2015-12-09 16:30:46" + }, + { + "name": "jms/cg", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/cg-library.git", + "reference": "2152ea2c48f746a676debb841644ae64cae27835" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/cg-library/zipball/2152ea2c48f746a676debb841644ae64cae27835", + "reference": "2152ea2c48f746a676debb841644ae64cae27835", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-0": { + "CG\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache2" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Toolset for generating PHP code", + "keywords": [ + "code generation" + ], + "time": "2016-04-07 10:21:44" + }, + { + "name": "jms/di-extra-bundle", + "version": "1.8.1", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/JMSDiExtraBundle.git", + "reference": "53d0a974d79f1793a4168fbafe98f273d3e1b3e0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/JMSDiExtraBundle/zipball/53d0a974d79f1793a4168fbafe98f273d3e1b3e0", + "reference": "53d0a974d79f1793a4168fbafe98f273d3e1b3e0", + "shasum": "" + }, + "require": { + "jms/aop-bundle": "~1.1", + "jms/metadata": "~1.0", + "php": "~5.3|~7.0", + "symfony/dependency-injection": "~2.3|~3.0", + "symfony/finder": "~2.3|~3.0", + "symfony/framework-bundle": "~2.3|~3.0", + "symfony/http-kernel": "^2.3.24|~3.0", + "symfony/process": "~2.3|~3.0", + "symfony/routing": "~2.3|~3.0" + }, + "require-dev": { + "doctrine/doctrine-bundle": "~1.5", + "doctrine/orm": "~2.3", + "jms/security-extra-bundle": "~1.0", + "phpcollection/phpcollection": ">=0.2,<0.3-dev", + "sensio/framework-extra-bundle": "~2.0|~3.0", + "symfony/browser-kit": "~2.3|~3.0", + "symfony/class-loader": "~2.3|~3.0", + "symfony/expression-language": "~2.6|~3.0", + "symfony/form": "~2.3|~3.0", + "symfony/phpunit-bridge": "~2.7", + "symfony/security-bundle": "~2.3", + "symfony/twig-bundle": "~2.3|~3.0", + "symfony/validator": "~2.3|~3.0", + "symfony/yaml": "~2.3|~3.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "1.8-dev" + } + }, + "autoload": { + "psr-4": { + "JMS\\DiExtraBundle\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Allows to configure dependency injection using annotations", + "homepage": "http://jmsyst.com/bundles/JMSDiExtraBundle", + "keywords": [ + "annotations", + "dependency injection" + ], + "time": "2016-09-18 13:06:50" + }, + { + "name": "jms/metadata", + "version": "1.6.0", + "source": { + "type": "git", + "url": "https://github.com/schmittjoh/metadata.git", + "reference": "6a06970a10e0a532fb52d3959547123b84a3b3ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/schmittjoh/metadata/zipball/6a06970a10e0a532fb52d3959547123b84a3b3ab", + "reference": "6a06970a10e0a532fb52d3959547123b84a3b3ab", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "doctrine/cache": "~1.0", + "symfony/cache": "~3.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5.x-dev" + } + }, + "autoload": { + "psr-0": { + "Metadata\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Johannes M. Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Class/method/property metadata management in PHP", + "keywords": [ + "annotations", + "metadata", + "xml", + "yaml" + ], + "time": "2016-12-05 10:18:33" + }, { "name": "kriswallsmith/assetic", "version": "v1.4.0", diff --git a/src/AppBundle/Controller/PanelController.php b/src/AppBundle/Controller/PanelController.php new file mode 100644 index 0000000..ece714d --- /dev/null +++ b/src/AppBundle/Controller/PanelController.php @@ -0,0 +1,82 @@ +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); + } +} \ No newline at end of file diff --git a/src/AppBundle/Controller/PublicController.php b/src/AppBundle/Controller/PublicController.php new file mode 100644 index 0000000..b9d50fd --- /dev/null +++ b/src/AppBundle/Controller/PublicController.php @@ -0,0 +1,19 @@ +render('landing.html.twig'); + } +} \ No newline at end of file