Symfony 3.4-如何装饰UrlGenerator

时间:2018-11-17 11:29:09

标签: php symfony symfony-3.4

我想装饰Symfony UrlGenerator类。

我已将其添加到services.yml中,但是我的AppBundle \ Service \ UrlGenerator类被忽略:

Symfony\Component\Routing\Generator\UrlGenerator: ~

my.url_generator:
    class: AppBundle\Service\UrlGenerator
    decorates: Symfony\Component\Routing\Generator\UrlGenerator
    arguments: ['@my.url_generator.inner']
    public:    false

现在,我知道我可以通过覆盖一些路由器选项来实现这一点,但是现在我认为这已经贬值了:

router.options.generator_class: AppBundle\Service\UrlGenerator
router.options.generator_base_class: AppBundle\Service\UrlGenerator

但是有效。我想知道有没有办法装饰UrlGenerator?另外,如何将ParameterBag添加到装饰类中?

0 个答案:

没有答案