hsz
hsz

Reputation: 152304

Extend parent bundle and keep its routing

I'm trying to create a core AppBundle and an extension on the top (mainly changes in UI). I have created following structure:

src/
├── AppBundle
│   ├── AppBundle.php
│   ├── Controller
│   │   └── DefaultController.php
│   └── Resources
│       └── views
│           └── Default
│               └── index.html.twig
└── HszBundle
    ├── Controller
    │   └── MenuController.php
    ├── HszBundle.php
    └── Resources
        ├── public
        │   └── less
        │       └── hsz.less
        └── views
            └── Default
                └── index.html.twig

Main /app/config/routing.yml loads rules from annotations:

app:
    resource: "@AppBundle/Controller/"
    type:     annotation

hsz:
    resource: "@HszBundle/Controller/"
    type:     annotation

AppBundle\Controller\DefaultController contains one rule:

/**
 * Class DefaultController
 * @package AppBundle\Controller
 */
class DefaultController extends Controller
{
    /**
     * @Route("/", name="root")
     * @Template
     */
    public function indexAction()
    {
        return [];
    }
}

and HszBundle\Controller\MenuController contains:

/**
 * Class MenuController
 *
 * @package HszBundle\Controller
 * @Route("/menu")
 */
class MenuController extends Controller
{
    /**
     * @Route("/list")
     * @Ajaxable
     */
    public function listAction()
    {
        return [];
    }
}

HszBundle has set getParent method to return AppBundle. The problem is that AppBundle routings are ignored and contains only:

hsz_menu_list         ANY    ANY    ANY  /menu/list                        

If getParent is not overwritten, it returns all routings:

root                  ANY    ANY    ANY  /                                 
hsz_menu_list         ANY    ANY    ANY  /menu/list              

but with no extending features.

How can I import all AppBundle routings when extending the bundle ?

Upvotes: 0

Views: 45

Answers (1)

Tom
Tom

Reputation: 1223

As far as I know it is not possible. Read the docs How to Override any Part of a Bundle

Upvotes: 1

Related Questions