sonata-project/SonataDoctrineORMAdminBundle — pull request #407 by Soullivaneuh (2014-11-28 17:49:33+00:00)
Title: Fix ProxyQuery error on relational identifiers

Actually, the ProxyQuery can't handle identifier with relational link properly. This PR patch this.

It's a corrected version of #226 and concern issus #225, https://github.com/sonata-project/SonataAdminBundle/issues/1392 and https://github.com/sonata-project/SonataAdminBundle/issues/1000 as far I know.

I think it's quite critical, please have a look! :+1:

Thanks.

I give you some steps to reproduce the error with the current master version.

If we have an entity with relational identifiers like this:

```php
/**
* UserBrowser
*
* @ORM\Table(name="user_browser")
* @ORM\Entity
*/
class UserBrowser
{
const UPDATE_GAP = 1800;
const NOTIFY_GAP = 60;

/**
* @var User
*
* @ORM\Id
* @ORM\ManyToOne(targetEntity="Nexy\UserBundle\Entity\User", inversedBy="browsers")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
private $user;

/**
* @var User
*
* @ORM\Id
* @ORM\ManyToOne(targetEntity="AppBundle\Entity\Browser")
* @ORM\JoinColumn(name="browser_id", referencedColumnName="id")
*/
private $browser;

// [...]
```

And a configured admin like this:

```php
/**
* Class UserBrowserAdmin
*/
class UserBrowserAdmin extends Admin
{
protected $baseRouteName = 'admin_user_browser';
protected $baseRoutePattern = 'user/browser';
protected $datagridValues = array(
'_sort_by' => 'lastUsedAt',
'_sort_order' => 'DESC',
);

protected function configureListFields(ListMapper $list)
{
$list
->addIdentifier('user')
->addIdentifier('browser')
->add('lastUsedAt')
->add('_action', 'actions', array(
'actions' => array(
'show' => array(),
)
))
;
}

protected function configureShowFields(ShowMapper $filter)
{
$filter
->add('user')
->add('browser.id')
->add('lastUsedAt')
->add('browser.details')
;
}
}
```

We got this error:

```
An exception has been thrown during the rendering of a template ("[Semantical Error] line 0, col 18 near 'user FROM AppBundle\Entity\UserBrowser': Error: Invalid PathExpression. Must be a StateFieldPathExpression.") in SonataAdminBundle:CRUD:base_list.html.twig at line 33.
```