2011-06-13 3 views
0

symfony 응용 프로그램에서 doctrine admin generator를 기반으로 만들어진 모듈 목록이 있습니다. 앱이 다른 시스템에 내장되어 있기 때문에 sfAction.class.php의 액션 클래스에있는 모든 redirect() 호출을 대체해야합니다. 모든 모듈에 붙여 넣을 수는 있지만 사용할 수있는 곳이 있습니까?응용 프로그램의 모든 모듈에 대해 redirect()를 넣을 위치

원래 리디렉션 (심포니/lib 디렉토리/액션/sfACtion.class.php)

public function redirect($url, $statusCode = 302) 
{ 
// compatibility with url_for2() style signature 
if (is_object($statusCode) || is_array($statusCode)) 
{ 
    $url = array_merge(array('sf_route' => $url), is_object($statusCode) ? array('sf_subject' => $statusCode) : $statusCode); 
    $statusCode = func_num_args() >= 3 ? func_get_arg(2) : 302; 
} 

$this->getController()->redirect($url, 0, $statusCode); 

throw new sfStopException(); 

}

내 변화

function redirect($url, $statusCode = 302){ 
    if (is_object($statusCode) || is_array($statusCode)){ 
     $url = array_merge(array('sf_route' => $url), is_object($statusCode) ? array('sf_subject' => $statusCode) : $statusCode); 
     $statusCode = func_num_args() >= 3 ? func_get_arg(2) : 302; 
    } 

    if (is_array($url)){ 
     $use_url = $this->getController()->genUrl($url, true); 
    }else if (substr($url,0,1) == '@'){ 
     $use_url = $this->getController()->genUrl($url, true); 
    }else{ 
     $use_url = $url; 
    } 
    $url = NZGBCTools::makeUriJoomlaCompatible($use_url);  

    $this->getController()->redirect($url, 0, $statusCode); 

    throw new sfStopException(); 

} 

답변

0

, sfActions를 확장하는 새로운 클래스를 생성하고 귀하의 행동 수업을 확장하십시오. 이렇게하면 필요한 핵심 장소를 갖게됩니다.

+0

고마워, 그게 효과가있다, 나는 "심포니 장소"를 찾고 있었지만, 나에게 도움이 될 것이다. – jdog

+0

이것은 가능한 한 "심포니 장소"입니다. 심포니 기본 클래스를 확장하면 많은 일을 쉽게 할 수 있습니다. 멋진 예를 보려면 http://www.symfony-project.org/more-with-symfony/1_4/en/02-Advanced-Routing을 참조하십시오. – Maerlyn

관련 문제