Silex将中间件设置为ControllerCollection



我想这样做:

$app->mount('dashboard', new TravelControllersDashboard())->before(function() use ($app) {
              //check if is logued...
            })

有可能吗?

谢谢!

你可以做

$controllers = $app["controllers_factory"];
$controllers->before(function(Request $request){});

in you ControllerProviderInterface::connect method

如果你需要在$app定义php文件中定义一个函数,你可以创建一个受保护的函数

$app['callback'] = $app->protect(function(){});
然后

$controllers->before($app["callback"]);

相关内容

  • 没有找到相关文章

最新更新