2
에서 코드 중복을 줄일 수 있습니다. UserTypeA 및 UserTypeB, (예를 들어, 코멘트는 사용자가 A 형의 제품에 할당 한)을 ManyToOne 관계의 속성을 포함 : 는 어떻게 3 "주"개체가 Symfony2
나는이 "보조"개체가 있습니다. 이 두 엔티티와 리포지토리는 비슷합니다 (단 하나는 TypeA에 연결되고 다른 하나는 TypeB에 연결됨). 여기 내 코드의 일부이다 : 당신이 볼 수 있듯이public function typea_commentAction(TypeA $typea)
{
$user = $this->getUser();
$userTypeA = $this->getDoctrine()
->getManager()
->getRepository('GamUserBundle:UserTypeA')
->getComment($user, $typea);
//...
}
public function typeb_commentAction(TypeB $typeb)
{
$user = $this->getUser();
$userTypeB = $this->getDoctrine()
->getManager()
->getRepository('GamUserBundle:UserTypeB')
->getComment($user, $typeb);
//...
}
, 나는 그들 각각의 개체와 함께 작동하도록 각 작업을 복제해야합니다. 이러한 작업을 결합 할 수있는 방법이 있습니까? 보조 엔티티와 리포지토리에 대해 동일한 질문이 있습니다.
감사합니다.
감사합니다. 그것은 내가 필요한 것입니다. – blugeen