I try to add my dynamic route like a service. routes.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();
}
}
How to make my dynamic route not fall into this file:
/cache/appProductionDebugSilexProjectContainerUrlMatcher.php
/cache/appProductionDebugSilexProjectContainerUrlGenerator.php
Example:
- I have a route localhost/dynamic-pages/page1
Then in the admin panel, I rename my route for page2 - I have a route localhost/dynamic-pages/page1
Then in the admin panel, I remove this route.
In the final, I have a problem because this route exists in the cache folder.