如果我有一個關聯對象是一個集合,我可以限制結果嗎?在Symfony/Doctrine中過濾關聯實體集合
例如:生產者實體具有屬性翻譯,其中包含其他實體(生產者翻譯)的集合。
class Producer
{
protected $id;
// ArrayCollection
protected $translations;
}
ProducerController:
$producers = $this->getDoctrine()
->getRepository('ProducerBundle:Producer')
->findAll();
結果:
Producer
id: 1
translations:
en: ProducerTranslation
de: ProducerTranslation
這是正常的。但我只想得到一種語言的一個實體。 預期結果:
$producers = $this->getDoctrine()
->getRepository('ProducerBundle:Producer')
->findByLocale('en');
Producer
id: 1
translations:
en: ProducerTranslation
如何做到這一點?