다른 컨트롤러에서 함수를 호출 할 수 있습니까? 난 당신이 설치된 모든 extbase 확장의 모든 저장소를 삽입 할 수 categoryRepository.phpTYPO3 - 다른 저장소 호출
에서public function listAction() {
$this->settings['flexform']['showCategory'] ? $catId = $this->settings['flexform']['showCategory']:$catId = $this->settings['listView']['showCategory'];
// print $catId;
if (!$catId || $this->settings['flexform']['showCategory'] == '-1') {
$designs = $this->designRepository->findAll();
} else {
// $designs = $this->designRepository->findByCategory($catId);
$designs = $this->designRepository->findByCategoryGrouped($catId); // THIS
$categories = $this->categoryRepository->getCategories($catId); // THIS
}
// indhold forsvinder hvis næste linje slettes
$this->view->assign('designs', $designs, "L", $GLOBALS['TSFE']->sys_language_uid);
$this->view->assign('catId', $catId);
$this->view->assign('categories', $categories);
}
위의 코드에서 내 listAction은 designController.php입니다. 해당 파일에 내가 추가해야됩니다 /** * 확장 \ 도메인 \ 저장소 \이 SomeRepository * (에서) */ 보호 $ someRepository를 주입 \ var에 \ 공급 업체 (에서); categoryController.php를 만들고 거기에 추가해야합니까? –
새 컨트롤러를 생성하지 않아도됩니다. 그냥 당신의 designController에 categoryRepository를 삽입하면 (잘하면) designRepository와 함께 할 수 있습니다. – Daniel
'클래스 DesignController는 \ TYPO3 \ CMS \ Extbase \ MVC \ 컨트롤러 \ ActionController { \t/** \t * designRepository \t * \t * (에서) VAR \ TYPO3 \ OrigKentaurProducts \ 도메인 \ 저장소 \ DesignRepository \t를 확장 * (at) 주입 \t */ \t 보호 된 $ 디자인 리포 지 토리; \t \t/** \t * (에서) VAR \ TYPO3 \ OrigKentaurProducts \ 도메인 \ 저장소 \ CategoryRepository \t * \t */ \t 보호 $ categoryRepository를 주입 (에서); ' 및 : '$ categories = $ this-> categoryRepository-> getCategories ($ catId);' 저를 제공 내가 가진 CategoryRepository.php에서 "가 아닌 객체에 멤버 함수 getCategories()를 호출"줄 바꿈 누락 –