我想在Expressive中使用FastRoute的路由组。 像样品:
$router = $app->getContainer()->get(FastRoute\RouteCollector::class);
$router->get('/', App\Action\HomePageAction::class);
$router->addGroup('/pages', function (FastRoute\RouteCollector $router) {
$router->get('', App\Action\PagesIndexAction::class);
$router->get('/add', App\Action\PagesAddAction::class);
$router->get('/edit/{id}', App\Action\PageEditActionFactory::class);
$router->post('/edit/{id}', App\Action\PageEditActionFactory::class);
$router->get('/another/{section}[/{subsection}]', PagesAnotherActionFactory::class);
});
我在docs(https://docs.zendframework.com/zend-expressive/features/router/fast-route/#advanced-configuration)中创建了工厂
并在router.global.php
:
// ...
'factories' => [
FastRoute\RouteCollector::class => App\Container\FastRouteCollectorFactory::class,
FastRoute\DispatcherFactory::class => App\Container\FastRouteDispatcherFactory::class,
Zend\Expressive\Router\RouterInterface::class => App\Container\RouterFactory::class,
],
// ...
现在我无法弄清楚在哪里编写配置以及如何激活它。
可以在文件config/router.php
中完成吗?
请帮帮我。
答案 0 :(得分:1)
只要文件与配置的其余部分合并,您就可以将它们放在'dependencies' => [
//..
'invokables' => [
/* ... */
// Comment out or remove the following line:
// Zend\Expressive\Router\RouterInterface::class => Zend\Expressive\Router\FastRouteRouter::class,
/* ... */
],
'factories' => [
/* ... */
// Add this line; the specified factory now creates the router instance:
FastRoute\RouteCollector::class => App\Container\FastRouteCollectorFactory::class,
FastRoute\DispatcherFactory::class => App\Container\FastRouteDispatcherFactory::class,
// Zend\Expressive\Router\RouterInterface::class => Zend\Expressive\Router\FastRouteRouterFactory::class, // replaced by following line
Zend\Expressive\Router\RouterInterface::class => App\Container\RouterFactory::class,
/* ... */
],
],
中。
dependencies
请注意RouterFactory
密钥,并且您自己的FastRouteRouterFactory
会替换joined_layer=QgsVectorLayer(path,name,"ogr")
intersected_layer=QgsVectorLayer(path,name,"ogr")
featuresJ=joined_layer.getFeatures()
featuresI=intersected_layer.getFeatures()
featuresB=Bld_layer.getFeatures()
for fJ in featuresJ:
for fI in featuresI:
geomI=fI.geometry() #lo piglia
for fB in featuresB: geomB=fB.geometry()
if geomI.area()*2>=geomB.area():
val= fI[1]
else:
val= fJ[2]
print val
,因为它共享相同的配置密钥。
答案 1 :(得分:0)
不支持,我不确定是否可以在FastRoute中实现。
您可以查看主题" Zend router - child routes"