2013-03-04 1 views
-1

에서 작동하지 않는 인덱스를 실행하도록 설정 :이 FOSUserBundle와 Symfony2 재 내가 경로 "<code>/</code>"내 기본 컨트롤러가 컨트롤러

public function indexAction() { 
    if ($this->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY')) { 
     //render the logged in view(s) 
     $response = $this->render('Pan100MoodLogBundle:Default:index.html.twig'); 
    } else { 
     //redirect to the login controller 
     $response = $this->redirect($this->generateUrl('login')); 
    } 
    return $response; 
} 

그러나 심포니는 경로를 찾을 수 없습니다 :

경로를 " 로그인 "이 존재하지 않습니다. 500 내부 서버 오류 - RouteNotFoundException

무엇이 잘못 될 수 있습니까? FOSUserBundle을 사용하고 있습니다. 그것은처럼 보이는 fos_user_security_login

$response = $this->redirect($this->generateUrl('fos_user_security_login')); 

답변

1

당신은 리디렉션 할 수 있습니다. 당신은 당신의 route.yml에서 그것을 만들 필요가 | XML 파일,하지만, 컨트롤러를 지정해야 FOS가 YML이처럼 그것을 처리하는 원인이되지 않습니다

login: 
    pattern: /login 

편집 : 죄송합니다, 내 실수, 물론 레이아웃, 로그인하지 않습니다. 그러나 해안에 있습니다, 경로가로드 되었습니까? 원인 generateUrl은 경로 이름을 예상합니다. 당신이

php app/console router:debug 

를 입력하면

0

, 당신은 이름이 '로그인'과 경로가 없습니다에

+0

시도? – Piddien

+0

이것을 config/routing에 넣었지만 작동하지 않았습니다. 내 대답에 묘사 된 방식대로 작동하지만 올바른 일이 아닌지 잘 모르겠다. – Piddien

3

당신은 모든 응용 프로그램의 경로를 볼 수 있습니다. php app/console router:debug | grep login

, 그것은 보여줍니다

fos_user_security_login    ANY  /login 
fos_user_security_check    ANY  /login_check 

그래서 당신은 레이아웃을 의미

$response = $this->redirect($this->generateUrl('fos_user_security_login')); 
관련 문제