젠드 프레임 워크를 사용하여 웹 응용 프로그램을 개발 중입니다. 나는 모든 오토 로딩이 어떻게 작동하는지는 좋아하지만, Zend_Controller가 컨트롤러의 이름을 기본적으로 지정하는 방식이 마음에 들지 않습니다. zend_controller가 {$ app} /Controller/User.php에 저장된 Controller_User라는 컨트롤러 클래스를 이해할 수있는 방법을 찾고 있습니다. 어쨌든 최소한 여분의 코드로이 작업을 수행 할 수 있습니까?Zend_Controller 다음 PEAR 명명 규칙
1
A
답변
0
(http://cslai.coolsilon.com/2009/03/28/extending-zend-framework/ 인용) 서브 클래 싱 운영자
class Coolsilon_Controller_Dispatcher
extends Zend_Controller_Dispatcher_Standard {
public function __construct() {
parent::__construct();
}
public function formatControllerName($unformatted) {
return sprintf(
'Controller_%s', ucfirst($this->_formatName($unformatted))
);
}
public function formatActionName($unformatted) {
$formatted = $this->_formatName($unformatted, true);
return strtolower(substr($formatted, 0, 1)) . substr($formatted, 1);
}
}
2
이것은 분명히 단계별 답변이 아니지만 표준 디스패처 클래스를 서브 클래 싱하고 컨트롤러 디렉토리 및 컨트롤러 객체를 처리하는 함수를 약간 변경하여 원하는 결과를 얻을 수 있다고 생각합니다. ZF Ref Guide - Subclassing Dispatcher