An extension to Symfony2 FrameworkBundle that adds annotation configuration for Controller classes
PHP HTML
Latest commit 3c82ce4 Sep 22, 2016 @fabpot fabpot feature #432 Adding a new expr option for the Doctrine param converte…
…r (weaverryan)

This PR was squashed before being merged into the 4.0.x-dev branch (closes #432).

Discussion
----------

Adding a new expr option for the Doctrine param converter

Fulfills #321

This simply extends the `DoctrineParamConverter`, allowing for this:

```php
/**
 * @Route("/post/{slug}")
 * @ParamConverter("post", options={"expr":"repository.findOneBySlug(slug)"})
 */
public function showAction(Post $post)
```

Of course, `options` is super ugly :). So I've sub-classed `ParamConverter` with a type that simply makes setting the `expr` option much nicer:

```php
/**
 * @Route("/post/{slug}")
 * @Entity("post", expr="repository.findOneBySlug(slug)")
 */
public function showAction(Post $post)
```

All request attributes become variables + `repository` are variables in the expression. No expression functions were added... because I think it's just this simple. All existing functionality is unchanged. In fact, in this example,  you probably don't even need the annotation, since `slug` is probably the field name.

P.S. This is compatible/consistent with the version 4 changes in #431.

Cheers!

Commits
-------

836f17b Adding a new expr option for the Doctrine param converter

README.md

SensioFrameworkExtraBundle

This bundle provides a way to configure your controllers with annotations.

Read about it on its official homepage.