I'm looking for the good way to use KnplabsDoctrineBehaviors with SonataAdmin.
I have already render a form in sonata admin bundle with the help of this bundle : https://github.com/a2lix/TranslationFormBundle It works fine and add correctly an entity with its translations.
To list entities in sonata I found the hack from this but when I add sortable property to Nom in listMapper of Sonata-admin it does not work.
class Sport
{
use \Knp\DoctrineBehaviors\Model\Translatable\Translatable;
public function __call($method, $arguments)
{
return $this->proxyCurrentLocaleTranslation($method, $arguments);
}
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
// Need this method for the admin list template
public function getNom(){
return $this->translate()->getNom();
}
// Work even the precedent method not here, the proxy call work fine.
public function __toString(){
return $this->getNom();
}
}
class SportTranslation
{
use ORMBehaviors\Translatable\Translation;
/**
* @ORM\Column(type="string", length=255)
*/
protected $nom;
/**
* @return string
*/
public function getNom()
{
return $this->nom;
}
/**
* @param string
* @return null
*/
public function setNom($nom)
{
$this->nom = $nom;
}
}
When I try to sort by Nom I get this error :
Catchable Fatal Error: Argument 1 passed to
Sonata\DoctrineORMAdminBundle\Datagrid\ProxyQuery::entityJoin()
must be of the type array, null given, called in
.../vendor/sonata-project/doctrine-orm-admin-bundle/Sonata/DoctrineORMAdminBundle/Datagrid/ProxyQuery.php
on line 140
and defined in
.../vendor/sonata-project/doctrine-orm-admin-bundle/Sonata/DoctrineORMAdminBundle/Datagrid/ProxyQuery.php
line 245
I guess it's because Nom is not in Sport and I don't know how to handle this.