2016-12-14 25 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

関連する問題