1
我有一个使用Symfony CMF路由束1.3的Symfony 2.6应用程序,其中我们使用常规symfony路由和动态路由的组合来定制商店(其中包括以下示例关注我们的动态路由器之一)。Symfony CMF动态路由器“无法匹配”日志
问题是,我们正在无休止地记录有关路由器无法匹配动态路由时,他们工作得很好。
最常见的条目存在:
Router Symfony\Bundle\FrameworkBundle\Routing\Router was not able to match, message ""
我们偶尔看到
Router Symfony\Cmf\Bundle\RoutingBundle\Routing\DynamicRouter was not able to match, message ""
有没有一种方法来禁用这些日志或更改我的动态路由器的配置/设置,使这些错误只出现在该路线实际上失败。
这里是我的配置/设置:
# 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
而基于
// 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)
{
}
}
如果那里有一个更好的方式来使用动态路由我很想听到它的实际动态路由器:)
我如何设置调试我不知道。踢自己吧!谢谢 – Nick
不要踢,如果有帮助,很高兴 – dbu