I'm trying to override some parts of the FOSUserBundle.
I have to custom the ProfileController (especially the showAction). I looked for a solution, and found that I had to create a new ProfileController in my UserBundle, and inherits the original FOSUserBundle ProfileController.
That's what I have done.
use FOS\UserBundle\Controller\ProfileController as BaseController;
class ProfileController extends BaseController
I also know how to override twig views by creating same name files in my own UserBundle.
My problem is, that I don't know how to make Symfony using my ProfileController instead of the original.
Do I have to change routes in App/Config/routing.yml ?
Or simply create an .xml routing file in my UserBundle, and then import it in App/Config/routing.yml?
I first made the mistake of customing FOSUserBundle files but I know it wasn't the right way, that's why I'm trying to do clean changes now.
The
ProfileControlleris registered as a service namedfos_user.profile.controlleras you can see in this configuration file.In order to override the controller/service (for Symfony 3.4) you need to re-define this service inside your
app/config/services.yml:Now clear your cache. Symfony will then use your ProfileController class as the service named
fos_user.profile.controller.