2016-12-14 1 views
0

메서드 이름 또는 authentification 메서드에서 호출 된 URL을 silex 클래스에서 검색하려고합니다. Silex에서 호출 된 메서드를 확인하는 방법

이 나는 ​​연결 기능 내 메서드를 호출하는 방법 : 내가 호출 방법을 얻을하고자하는 인증 기능을 호출하고있어 모든 메소드 전에

$controllers->get('/list/reviews/', array($this, 'actionAllReviews')) 
     ->before(array($this, 'controlerAuthentification')); 

합니다. 내 경우에는 actionAllReviews 또는 /list/reviews/입니다.

public function controlerAuthentification(Request $request, Application $app) 
{ 
    if(!$this->getClient()){ 
     $app->abort(404,'Wrong client informations'); 
    } 

    //How can I get the information here ? 
} 

답변

1

는 렉스는 경로 이름을 포함하는 $request_route 속성을 추가 할 수 있습니다. 당신은 그것을 사용할 수 있습니다.

$routeName = $request->attributes->get('_route'); 
+0

감사합니다. 그것의 작동! – KubiRoazhon

관련 문제