Question

So I read alot about the overriding of templates and such and overriding of bundles in Symfony.

I am using the new Symfony 2.3, I have not tried this in lower versions of Symfony.

I followed the tutorial about overriding bundles in Symfony: http://symfony.com/doc/2.3/cookbook/bundles/inheritance.html

I followed the tutorial about overriding the controllers of FOSUserBundle, which is the same thing really: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/doc/overriding_controllers.md

I had a bundle named Acme/WebBundle.

Now I have done the following things:

  • Created a new bundle named Acme/UserBundle.
  • Created the file AcmeUserBundle.php in this bundle.

    <?php
    
    namespace Acme\UserBundle;
    
    use Symfony\Component\HttpKernel\Bundle\Bundle;
    
    class AcmeUserBundle extends Bundle
    {
        public function getParent()
        {
            return 'FOSUserBundle';
        }
    }
    
  • Created the following file structure:

    -src
        -Acme
            -UserBundle
                -Controller
                    RegistrationController.php
                -Entity
                    User.php
                -Resources
                    -translations
                    -views
                AcmeUserBundle.php
    
  • In RegistrationController.php I set the namespace to:

    namespace Acme\UserBundle\Controller;
    
  • Copied the contents of the registration controller of FOSUserBundle to mine.

  • Added to the beginning of registerAction()

    die("message");
    

Now when I go to the registration form, the default /register route, I don't get a die, everything works fine. It does not see my bundle as a child, nothing is overridden and I've been trying to get it to work for ages hence my question here.

Did I do something wrong?

Was it helpful?

Solution

Remember that you need to add any new bundle to AppKernel::registerBundles() in app/AppKernel.php like this:

    $bundles = array(
        ...
        new Acme\UserBundle()
    );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top