anotherdev
anotherdev

Reputation: 2569

Symfony bundle parent services.yml ignored

I have 2 bundle MyBundle1 and MyBundle2 , MyBundle2 inherits MyBundle1.

In /app/config/services.yml i have:

imports: - resource: '@MyBundle1/Resources/config/services.yml' - resource: '@MyBundle2/Resources/config/services.yml'

The problem is that '@MyBundle2/Resources/config/services.yml' will be considered as '@MyBundle1/Resources/config/services.yml' because it inherits it, so override its files.

My question is: How can I access to the real '@MyBundle2/Resources/config/services.yml', not the one rewritten ?

Thanks

Upvotes: 0

Views: 165

Answers (1)

Kep
Kep

Reputation: 5857

The Symfony cookbook explains that Bundles override their parent Bundles resource files when

  1. they're in the same location inside the bundle
  2. They've been imported using the @MyBundle/...../services.yml (the @-part) syntax.

In order to have your Bundle not override your parent Bundles services you can use a different filename (eg. _services.yml) or refer to it using the full path in your config.

Upvotes: 2

Related Questions