在不同的控制器中是否可以调用一个函数?我需要在designRepository.php中调用FindByCategoryGrouped($catId)
,并在categoryRepository.php中调用getCategories($catId)
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);
}
/** * (at)var \Vendor\Extension\Domain\Repository\SomeRepository * (at)inject */ protected $someRepository;
还是应该创建categoryController.php并将其添加到其中? - Jeppe Donslund