데이터를 가져오고 가져 오는 방법이 60 가지 보고서 모두에서 언급 한 것과 매우 비슷하면. 60 개의 컨트롤러 (+ PHP 파일)를 만드는 것은 바보 같이 보일 것입니다.
기본 재 작성 라우터로이 문제를 해결하려고하는 것 같습니다. 라우터에 보고서 이름을 자동으로 저장하는 경로를 추가 할 수 있으며 논리를 추상화하여 일부 report-runner-business-object-thingy에 위임 할 수 있습니다. 컨트롤러에서이 같은
$router = $ctrl->getRouter(); // returns a rewrite router by default
$router->addRoute(
'reports',
new Zend_Controller_Router_Route('reports/:report_name/:action',
array('controller' => 'reports',
'action' => 'view'))
);
그리고 뭔가 ... 당신은 요점을 파악
public function viewAction() {
$report = $this->getRequest()->getParam("report_name");
// ... check to see if report name is valid
// ... stuff to set up for viewing report...
}
public function runAction() {
$report = $this->getRequest()->getParam("report_name");
// ... check to see if report name is valid
// Go ahead and pass the array of request params, as your report might need them
$reportRunner = new CustomReportRunner($report, $this->getRequest()->getParams());
$reportRunner->run();
}
; 이 도움이되기를 바랍니다!