This is quite a general question about extending vendor bundles, but I can cite extending CCDNUserUserBundle as a specific example.
I already have an application that extends FOSUserBundle. The problem I have is that my existing User entity has a few more fields than the User entity in CCDNUserUserBundle.
I have 2 ways that I can approach this:
1) Create an associated entity that houses these additional fields (easiest) or
2) Extend the existing CCDNUserUserBundle which is a lot harder as the bundle doesn't seem to have been written with this in mind, although I could be wrong.
Although the CCDN bundles are geared towards a Forum app, they usefully encompass other functions such as user management that I'd like to build on. To that end I've been looking at how to make the bundles extendable by looking at the CCDNUserUserBundle as it's the first one I have a need to extend.
So on my own sandbox I've been playing with FOSUserBundle, writing bundle that extends it first (as normally required) and then rewriting it to make it extendable. This is where I run into problems. Is it even possible to write an extendable bundle that extends another extendable bundle? And just as importantly, how are the CCDN Bundles intended to be used (as an entire ecosystem or separable?).
Just to be clear; I'm not trying to extend a bundle twice, but extend a bundle which extends a bundle.
Edited by reece ·
11-11-2012 - 23:12
CCDNUserUserBundle is the only bundle i have written that is a child of another bundle.
All other bundles that i have written work as a base bundle that you can extend easily enough by making a child of that bundle.
As far as i am aware in Symfony2 there are no limitations to bundle inheritance. (This is in terms of creating a bundle as a child of another in SF2 terms). I confirmed this was the case in the IRC room with some of their resident gurus.
The UserBundle is really more geared towards creating a more integrated look and feel across the site with the templates than anything else as there are very few changes made to the bundle other than:
1) The login handlers i wrote to redirect the user to the last page they were on after a successful login. FOS does not come with any default redirect on login behaviour so i created my own.
2) I wrapped the profile controller of FOS with an account controller, because it interferes with the profile bundle, or perhaps did at some point in the past, it may not even be relevant anymore.
3) Extend the registration process to integrate the google recaptcha box to prevent spammers.
4) Add the dashboard integrator for the purposes of adding the FOS links to the dashboard.
I think the best thing now moving forward would be to create a new bundle and move the above functionality out of the FOS child bundle and into the new one. I could call it something like CCDNUser\UserExtraBundle or something.
In this way, we free up the UserBundle to be replaced by whatever you like, this would mean the only thing that you need to do is copy the UserBundle templates to your own UserBundle if you still wished to retain the templates, or create another user bundle only extending the templates you wish to change,
As for Administration features, these are provided by the CCDNUser\AdminBundle which will give you some basic administration features for getting started though the AdminBundle still needs work.
SF2 Docs - Bundle Inheritance