0
votes

I want to make a bundle that i would like other bundles to extend by either overwriting functionality or adding on to it. SYmfony supports that out of the box (http://symfony.com/doc/2.0/cookbook/bundles/inheritance.html) but what happens if multiple bundles tries to overwrite the same controller. Does it have a chain like effect where each bundle gets the response of the bundle before it or does the last bundle to extend the functionality only gets noticed? If its the latter, is there a way in symfony to allow the chain like method?

1

1 Answers

0
votes

I think you are getting confused with how 'overwriting' works. When you extend a class you can 'overwrite' a method in the base class by creating a method with the same name, but you are not actually affecting the base class in any way, so multiple classes can extend the same base class without interacting with each other.

In Symfony2, it is absolutely fine to extend a base controller from multiple different bundles. Any methods defined in this base class will be available in the classes you have used to extend it. Depending on your needs for this, you may also wish to look into services which can be defined to allow access to methods globally in your application.