I have a Symfony 2.6 application using Symfony CMF routing bundle 1.3 where we use a combination of normal symfony routes and dynamic routes for custom stores (amongst other things, the below example focuses on one of our dynamic routers).
The problem is that we are getting endless logs about the router not being able to match the dynamic routes when they work just fine.
The most common entry being:
Router Symfony\Bundle\FrameworkBundle\Routing\Router was not able to match, message ""
We occasionally see
Router Symfony\Cmf\Bundle\RoutingBundle\Routing\DynamicRouter was not able to match, message ""
Is there a way to disable these logs or change my dynamic router configuration/setup so that these errors only appear when the route actually fails.
Here is my config/setup:
# app/config/config.yml
cmf_routing:
chain:
routers_by_id:
router.default: 32
cmf_routing.dynamic_router: 30
dynamic:
enabled: true
route_provider_service_id: store_router
And the actual dynamic router based on
// StoreBundle/Router/StoreRouter.php
<?php
/**
* @DI\Service("store_router")
*/
class StoreRouter implements RouteProviderInterface
{
protected $em;
/**
* @DI\InjectParams({
* "em" = @DI\Inject("doctrine.orm.entity_manager")
* })
*/
public function __construct(EntityManager $em)
{
$this->em = $em;
}
/**
* @param Request $request
* @return RouteCollection
*/
public function getRouteCollectionForRequest(Request $request)
{
$collection = new RouteCollection();
$store = $this->em->getRepository('StoreBundle:Store')->findOneBySlug(substr($request->getPathInfo(), 1), $request->get('key', null));
// no store found, return an empty collection
if (empty($store)) {
return $collection;
}
$route = new Route(
'/' . $store->getSlug(),
[
'_controller' => 'StoreBundle:Store:view',
'slug' => $stote->getSlug()
]
);
$collection->add($store->getSlug(), $route);
return $collection;
}
public function getRouteByName($name, $params = [])
{
}
public function getRoutesByNames($names)
{
}
}
If theres a better way to use dynamic routes I'd love to hear it :)