我尝试将动态路由添加为服务。 route.yml:
static_pages:
resource: 'pages.dynamic_routing_provider:getRoutes'
type: service
Service.php
class DynamicRoutingProvider {
public function getRoutes(): RouteCollection
{
$builder = new RouteCollectionBuilder();
$options = [
'cache_dir' => null,
'generator_cache_class' => null
];
$route = new Route('dynamic-pages', ['_controller' => 'PagesBundle:Pages:preview'], [], $options);
$builder->addRoute($route);
return $builder->build();
}
}
如何使我的动态路由不属于该文件:
/cache/appProductionDebugSilexProjectContainerUrlMatcher.php
/cache/appProductionDebugSilexProjectContainerUrlGenerator.php
示例:
最后,我有一个问题,因为此路由存在于缓存文件夹中。