Skip to content

Commit 1672856

Browse files
committed
Removes dependency on Sensio Framework Extra Bundle
1 parent 02235e8 commit 1672856

File tree

7 files changed

+23
-19
lines changed

7 files changed

+23
-19
lines changed

README.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ This step can be skipped if you only use data URIs to display your images.
128128

129129
``` yml
130130
EndroidQrCodeBundle:
131-
resource: "@EndroidQrCodeBundle/Controller/"
132-
type: annotation
131+
resource: "@EndroidQrCodeBundle/Resources/config/routing.yml"
133132
prefix: /qrcode
134133
```
135134

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"symfony/templating": "^2.7|^3.0",
3131
"symfony/twig-bundle": "^2.7|^3.0",
3232
"symfony/yaml": "^2.7|^3.0",
33-
"sensio/framework-extra-bundle": "^3.0",
3433
"phpunit/phpunit": "^5.7|^6.0"
3534
},
3635
"autoload": {

src/Bundle/QrCodeBundle/Controller/QrCodeController.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
namespace Endroid\QrCode\Bundle\QrCodeBundle\Controller;
1111

1212
use Endroid\QrCode\Factory\QrCodeFactory;
13-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
14-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
1513
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
1614
use Symfony\Component\HttpFoundation\Response;
1715
use Symfony\Component\HttpFoundation\Request;
@@ -22,8 +20,6 @@
2220
class QrCodeController extends Controller
2321
{
2422
/**
25-
* @Route("/{text}.{extension}", name="endroid_qrcode_generate", requirements={"text"="[\w\W]+"})
26-
*
2723
* @param Request $request
2824
* @param string $text
2925
* @param string $extension
@@ -41,16 +37,21 @@ public function generateAction(Request $request, $text, $extension)
4137
}
4238

4339
/**
44-
* @Route("/twig", name="endroid_qrcode_twig_functions")
45-
* @Template()
46-
*
47-
* @return array
40+
* @return Response
4841
*/
4942
public function twigFunctionsAction()
5043
{
51-
return [
44+
if (!$this->has('twig')) {
45+
throw new \LogicException('You can not use the "@Template" annotation if the Twig Bundle is not available.');
46+
}
47+
48+
$param = [
5249
'message' => 'QR Code',
5350
];
51+
52+
$renderedView = $this->get('twig')->render('@EndroidQrCode/QrCode/twigFunctions.html.twig', $param);
53+
54+
return new Response($renderedView, Response::HTTP_OK);
5455
}
5556

5657
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
endroid_qrcode_generate:
2+
path: /{text}.{extension}
3+
requirements:
4+
text: "[\\w\\W]+"
5+
defaults:
6+
_controller: EndroidQrCodeBundle:QrCode:generate
7+
8+
endroid_qrcode_twig_functions:
9+
path: /twig
10+
defaults:
11+
_controller: EndroidQrCodeBundle:QrCode:twigFunctions

tests/Bundle/app/AppKernel.php

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public function registerBundles()
2020
$bundles = [
2121
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
2222
new Symfony\Bundle\TwigBundle\TwigBundle(),
23-
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
2423
new Endroid\QrCode\Bundle\QrCodeBundle\EndroidQrCodeBundle(),
2524
];
2625

tests/Bundle/app/bootstrap.php

-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
<?php
22

3-
use Doctrine\Common\Annotations\AnnotationRegistry;
4-
53
$loader = require __DIR__.'/../../../vendor/autoload.php';
6-
7-
AnnotationRegistry::registerLoader([$loader, 'loadClass']);

tests/Bundle/app/config/routing.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
EndroidQrCodeBundle:
2-
resource: "@EndroidQrCodeBundle/Controller/"
3-
type: annotation
2+
resource: "@EndroidQrCodeBundle/Resources/config/routing.yml"
43
prefix: /qrcode

0 commit comments

Comments
 (0)