2016-12-14 92 views
0

我正在尝试检索方法名称或authentification方法在一个silex类中调用的url。如何知道在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

的Silex添加_route属性包含路由名称对应的$request。你可以使用它。

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

谢谢。它的工作! – KubiRoazhon

相关问题