I have a few problems using Gedmo\DoctrineExtensions Translatable.
First is APY DataGrid - can't make it to show translated strings in grid on non default locale. If I use Translatable with default settings, all strings in grid are displayed in default language. If I implement Translatable in Entity and add annotations for table and other stuff, then I can see translated strings in grid, BUT after switching locales these stays the same. Seems like QueryCache is used, but can't find how to set not to use it. Here's a part for grid:
use APY\DataGridBundle\Grid\Source\Entity;
<...>
$source = new Entity('MainBundle:Entity');
$source->addHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
Of course it would be better to have translations without making annotations and separate entities for them.
Second problem is KNP pagination. Actually didn't dig into it, but similar problem.
The main problem is, when I run some query by translatable field of an entity. Let's say I have an Entity with name Krepšinis (it's basketball in Lithuanian) and I have translated this string to Basketball. Default language is LT. When in default language I perform a search, everything is ok, but if I change locale to EN and try searching for basket, it doesn't return any results and if I search for krep, it returns me Basketball. Code for search:
// Controller
$repository = $this
->getDoctrine()
->getManager()
->getRepository('MainBundle:Entity');
$query = $repository
->search($term)
->getQuery()
->useQueryCache(false)
->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
// Repository
public function search($query)
{
$qb = $this->createQueryBuilder('t');
$term = $qb->expr()->literal('%' . $query . '%');
$query = $qb->where($qb->expr()->like('t.name', $term));
return $query;
}
Any help is appreciated