엔티티에서 저장소 메소드를 호출 할 수 있습니까? 내 말은이 같은엔티티에서 저장소 메소드 호출
$article = $em->getRepository('Entities\Articles')->findOneBy(array('id' => $articleId));
$category = $em->getRepository('Entities\Categories')->findOneBy(array('id' => 86));
$article->addArticleToCategory($category);
addArticleToCategory이 저장소의 방법은 (단지 예제 코드)
public function addArticleToCategory($category){
$categoryArticles = new CategoryArticles();
$categoryArticles->setArticle(!!/** This is where I want to have my variable $article from this method call **/!!);
$categoryArticles->setCategory($category);
$this->getEntityManager()->persist($categoryArticles);
$this->getEntityManager()->flush();
}
그것을 할 수있는 가장 좋은 방법은 무엇입니까 어디?
또한 저장소에 사용자 정의 set/create 메소드를 넣는 것이 좋습니다.
그래서 저장소는 설정/추가 방법을 보유하는 데 사용됩니까? 아니면 그들은 단지 방법을 얻는 데 좋은가? –