I am using Symfony 6 + API Platform + Gedmo Translatable.
Updating / posting items is working perfectly and storing the translations correctly. Also getting a collection in the correct language is also working.
But when I try a GET-request on the translatable field, nothing comes up.
GET https://localhost/api/foos?name=bar
What is the correct way of querying the translatable field?
I've also added the query-hints like the docs stated.
This is my code (in really short):
App\Entity\Foo.php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\ApiFilter;
use Gedmo\Mapping\Annotation as Gedmo;
#[Gedmo\TranslationEntity(class: FooTranslation::class)]
#[ApiResource]
#[ApiFilter(SearchFilter::class, properties: [
'name' => 'partial',
])]
class Foo
{
#[Gedmo\Translatable]
private string $name = '';
/* And all getters/setters */
}
App\Entity\FooTranslation.php
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Translatable\Entity\MappedSuperclass\AbstractTranslation;
use Gedmo\Translatable\Entity\Repository\TranslationRepository;
#[ORM\Table(name: 'foo_translations')]
#[ORM\Index(columns: ['locale', 'object_class', 'field', 'foreign_key'], name: 'setting_translations_idx')]
#[ORM\Entity(repositoryClass: TranslationRepository::class)]
class FooTranslation extends AbstractTranslation
{
/**
* All required columns are mapped through inherited superclass
*/
}
There is
Gedmo\Translatable\Entity\Repository\TranslationRepositoryin Gedmo package and you can usepublic function findTranslations($entity)method