fsi-open/doctrine-extensions-bundle — pull request #34 by chives (2014-09-08 09:32:14+00:00)
Title: TranslatableParamConverter

**This PR can be merged only after https://github.com/fsi-open/doctrine-extensions/pull/45**

This PR introduces ``TranslatableParamConverter`` which allows converting URL parameters into action parameters of translatable classes. Let's assume we have a translatable entity class:

```php
# Acme/NewsBundle/Entity/News.php

namespace Acme/NewsBundle/Entity;

use Doctrine\ORM\Mapping as ORM;
use FSi\DoctrineExtensions\Translatable\Mapping\Annotation as Translatable;

/**
* @ORM\Entity()
*/
class News
{

# ...

/**
* @Translatable\Translatable(mappedBy="translations")
*/
private $slug;

/**
* @ORM\OneToMany(targetEntity="NewsTranslation", mappedBy="news", indexBy="locale")
*/
private $translations;

# ...

}
```

some route:

```yml
# Acme/NewsBundle/Resources/config/routing.yml

acme_news_details:
pattern: /news/{slug}
defaults: { _controller: acme.controller.news:detailsAction }

```

and finally some action in controller:

```php
# Acme/NewsBundle/Controller/NewsController.php

namespace Acme/NewsBundle/Controller;

use Acme/NewsBundle/News;

class NewsController
{
# ...
public function detailsAction(News $news)
{

}
# ...
}
```

Without ``TranslatableParamConverer`` the default ``DoctrineParamConverter`` integrated in ``sensio/framework-extra-bundle`` will not be able to figure out how to find ``News`` object because the ``$slug`` member is not an ORM-mapped field. With ``TranslatableParamConverter`` everything will work as expected and you won't even notice the difference between regular ORM entity and entity with translatable properties.