Symfony 4:我装饰了UrlGeneratorInterface,但未使用,它改用CompiledUrlGenerator

问题描述 投票:-1回答:1

我装饰了UrlGeneratorInterface,但未使用它,而改用了CompiledUrlGenerator。我可以看到发生这种情况的地方,即在getGenerator的Symfony \ Component \ Routing \ Router中,它专门检查CompiledUrlGenerator :: class。但是我不想重写原始的Symfony代码。我应该如何重写/装饰/扩展哪个类,以便始终选择我的类,因为我需要将特殊参数添加到路径中。预先谢谢!

symfony routing decorator symfony4 router
1个回答
0
投票

我找到了。

app.decorator.router:
    class: App\CoreBundle\Routing\Extension\Router
    decorates: 'router.default'
    arguments: ['@app.decorator.router.inner']

装饰实际上使所有软件包都使用您的路由器。

© www.soinside.com 2019 - 2024. All rights reserved.