Skip to content

Commit

Permalink
simplified controllers
Browse files Browse the repository at this point in the history
  • Loading branch information
bamarni committed Jul 10, 2012
1 parent 85901aa commit 2f989ed
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 56 deletions.
14 changes: 4 additions & 10 deletions Controller/Base64Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@

namespace Genemu\Bundle\FormBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

/**
* Class Base64Controller
*
* @author Olivier Chauvel <[email protected]>
*/
class Base64Controller extends Controller
class Base64Controller extends ContainerAware
{
/**
* @Route("/genemu_base64", name="genemu_base64")
*/
public function base64Action(Request $request)
public function base64Action()
{
$query = $request->server->get('QUERY_STRING');
$query = $this->container->get('request')->server->get('QUERY_STRING');
$datas = preg_split('([;,]{1})', $query);

return new Response(base64_decode($datas[2]), 200, array('Content-Type' => $datas[0]));
Expand Down
13 changes: 4 additions & 9 deletions Controller/ImageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,21 @@

namespace Genemu\Bundle\FormBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

use Genemu\Bundle\FormBundle\Gd\File\Image;

/**
* Class ImageController
*
* @author Olivier Chauvel <[email protected]>
*/
class ImageController extends Controller
class ImageController extends ContainerAware
{
/**
* @Route("/genemu_change_image", name="genemu_form_image")
*/
public function changeAction(Request $request)
public function changeAction()
{
$request = $this->container->get('request');
$rootDir = rtrim($this->container->getParameter('genemu.form.file.root_dir'), '/\\') . DIRECTORY_SEPARATOR;
$folder = rtrim($this->container->getParameter('genemu.form.file.folder'), '/\\') . DIRECTORY_SEPARATOR;

Expand Down
14 changes: 4 additions & 10 deletions Controller/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,21 @@

namespace Genemu\Bundle\FormBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

use Genemu\Bundle\FormBundle\Gd\File\Image;

/**
* Upload Controller
*
* @author Olivier Chauvel <[email protected]>
*/
class UploadController extends Controller
class UploadController extends ContainerAware
{
/**
* @Route("/genemu_upload", name="genemu_upload")
*/
public function uploadAction(Request $request)
public function uploadAction()
{
$handle = $request->files->get('Filedata');
$handle = $this->container->get('request')->files->get('Filedata');

$folder = $this->container->getParameter('genemu.form.file.folder');
$uploadDir = $this->container->getParameter('genemu.form.file.upload_dir');
Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions Resources/config/routing/base64.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="genemu_base64" pattern="/genemu_base64">
<default key="_controller">GenemuFormBundle:Base64:base64</default>
</route>

</routes>
11 changes: 11 additions & 0 deletions Resources/config/routing/image.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="genemu_form_image" pattern="/genemu_change_image">
<default key="_controller">GenemuFormBundle:Image:change</default>
</route>

</routes>
11 changes: 11 additions & 0 deletions Resources/config/routing/upload.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>

<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">

<route id="genemu_upload" pattern="/genemu_upload">
<default key="_controller">GenemuFormBundle:Upload:upload</default>
</route>

</routes>
3 changes: 1 addition & 2 deletions Resources/doc/captcha_gd/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ genemu_form:
``` yml
# app/config/routing.yml
genemu_base64:
resource: "@GenemuFormBundle/Controller/Base64Controller.php"
type: annotation
resource: "@GenemuFormBundle/Resources/config/routing/base64.xml"
```
* also your captcha should be small, because IE supports only 2083 characters in requests (otherwise they are just skipped).
Expand Down
3 changes: 1 addition & 2 deletions Resources/doc/jquery/file/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ genemu_form:
``` yml
genemu_upload:
resource: "@GenemuFormBundle/Controller/UploadController.php"
type: annotation
resource: "@GenemuFormBundle/Resources/config/routing/upload.xml"
```
## Default Usage:
Expand Down
3 changes: 1 addition & 2 deletions Resources/doc/jquery/image/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ genemu_form:
``` yml
genemu_image:
resource: "@GenemuFormBundle/Controller/ImageController.php"
type: annotation
resource: "@GenemuFormBundle/Resources/config/routing/image.xml"
```
## Default Usage:
Expand Down
21 changes: 0 additions & 21 deletions UPGRADE 2.1

This file was deleted.

36 changes: 36 additions & 0 deletions UPGRADE 2.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
UPGRADE to Symfony 2.1
======================

### JQuery Chosen

[BC BREAK] Widget option cannot specify the choice type anymore, you have to append the widget in the type name instead :

Before :
``` php
$formBuilder
->add('country', 'genemu_jquerychosen', array(
'widget' => 'country',
));
```
Now :
``` php
$formBuilder->add('country', 'genemu_jquerychosen_country');
```

### Routing

[BC BREAK] Routing is defined in xml files instead of annotations (to remove the depency with SensioFrameworkExtraBundle)

Before :
``` yml
# app/config/routing.yml
genemu_base64:
resource: "@GenemuFormBundle/Controller/Base64Controller.php"
type: annotation
```
Now :
``` yml
# app/config/routing.yml
genemu_base64:
resource: "@GenemuFormBundle/Resources/config/routing/base64.xml"
```

0 comments on commit 2f989ed

Please sign in to comment.