我试图创建一个一对多的关系和标准,这样Symfony2的实体标准,而params
/**
* Get translatedData
*
* @return translatedData collection
*/
public function getTranslatedData($language) {
$criteria = Criteria::create()->where(Criteria::expr()->eq("language", $language));
$result = $this->getAllTranslatedData()->matching($criteria)[0];
if (count($result) == 0){
$criteria = Criteria::create()->where(Criteria::expr()->eq("language", 'en'));
$result = $this->getAllTranslatedData()->matching($criteria)[0];
}
return $result;
}
基本上我想要一个实体的语言环境传递到实体,所以它会在返回translatedData小枝模板中的语言环境语言只需调用 {{mainEntity.translatedData.property}}(如果该语言中没有翻译的数据,它将回退到'en') 但在mainEntity上执行find()无法将任何参数传递给此函数。
任何想法是赞赏。
感谢
会使用提供此功能的第三方库作为选项吗? https://github.com/KnpLabs/DoctrineBehaviors#translatable – Gildas 2015-02-10 00:19:29
看一看,但我认为我的问题比这更容易。 只需要将请求传递给实体或参数。 – 2015-02-10 12:35:24