diff --git a/README.md b/README.md index 08ed3b3..e732875 100644 --- a/README.md +++ b/README.md @@ -128,8 +128,7 @@ This step can be skipped if you only use data URIs to display your images. ``` yml EndroidQrCodeBundle: - resource: "@EndroidQrCodeBundle/Controller/" - type: annotation + resource: "@EndroidQrCodeBundle/Resources/config/routing.yml" prefix: /qrcode ``` diff --git a/composer.json b/composer.json index 6c5bad8..bed1cdf 100755 --- a/composer.json +++ b/composer.json @@ -30,7 +30,6 @@ "symfony/templating": "^2.7|^3.0", "symfony/twig-bundle": "^2.7|^3.0", "symfony/yaml": "^2.7|^3.0", - "sensio/framework-extra-bundle": "^3.0", "phpunit/phpunit": "^5.7|^6.0" }, "autoload": { diff --git a/src/Bundle/QrCodeBundle/Controller/QrCodeController.php b/src/Bundle/QrCodeBundle/Controller/QrCodeController.php index d642ba5..389c420 100755 --- a/src/Bundle/QrCodeBundle/Controller/QrCodeController.php +++ b/src/Bundle/QrCodeBundle/Controller/QrCodeController.php @@ -10,8 +10,6 @@ namespace Endroid\QrCode\Bundle\QrCodeBundle\Controller; use Endroid\QrCode\Factory\QrCodeFactory; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; -use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Request; @@ -22,8 +20,6 @@ class QrCodeController extends Controller { /** - * @Route("/{text}.{extension}", name="endroid_qrcode_generate", requirements={"text"="[\w\W]+"}) - * * @param Request $request * @param string $text * @param string $extension @@ -41,16 +37,21 @@ public function generateAction(Request $request, $text, $extension) } /** - * @Route("/twig", name="endroid_qrcode_twig_functions") - * @Template() - * - * @return array + * @return Response */ public function twigFunctionsAction() { - return [ + if (!$this->has('twig')) { + throw new \LogicException('You can not use the "@Template" annotation if the Twig Bundle is not available.'); + } + + $param = [ 'message' => 'QR Code', ]; + + $renderedView = $this->get('twig')->render('@EndroidQrCode/QrCode/twigFunctions.html.twig', $param); + + return new Response($renderedView, Response::HTTP_OK); } /** diff --git a/src/Bundle/QrCodeBundle/Resources/config/routing.yml b/src/Bundle/QrCodeBundle/Resources/config/routing.yml new file mode 100644 index 0000000..bfc3228 --- /dev/null +++ b/src/Bundle/QrCodeBundle/Resources/config/routing.yml @@ -0,0 +1,11 @@ +endroid_qrcode_generate: + path: /{text}.{extension} + requirements: + text: "[\\w\\W]+" + defaults: + _controller: EndroidQrCodeBundle:QrCode:generate + +endroid_qrcode_twig_functions: + path: /twig + defaults: + _controller: EndroidQrCodeBundle:QrCode:twigFunctions diff --git a/tests/Bundle/app/AppKernel.php b/tests/Bundle/app/AppKernel.php index d4afa7a..d30b3de 100644 --- a/tests/Bundle/app/AppKernel.php +++ b/tests/Bundle/app/AppKernel.php @@ -20,7 +20,6 @@ public function registerBundles() $bundles = [ new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), - new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new Endroid\QrCode\Bundle\QrCodeBundle\EndroidQrCodeBundle(), ]; diff --git a/tests/Bundle/app/bootstrap.php b/tests/Bundle/app/bootstrap.php index ff87382..15c731c 100644 --- a/tests/Bundle/app/bootstrap.php +++ b/tests/Bundle/app/bootstrap.php @@ -1,7 +1,3 @@