扩展父包并保持其路由

Extend parent bundle and keep its routing

我正在尝试创建核心 AppBundle 和顶部的扩展(主要是 UI 中的更改)。我创建了以下结构:

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

主要 /app/config/routing.yml 从注释中加载规则:

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

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

AppBundle\Controller\DefaultController 包含一条规则:

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

HszBundle\Controller\MenuController包含:

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

HszBundle 已将 getParent 方法设置为 return AppBundle。 问题是 AppBundle 路由被忽略并且只包含:

hsz_menu_list         ANY    ANY    ANY  /menu/list                        

如果getParent没有被覆盖,则return所有路由:

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

但没有扩展功能。

如何在扩展包时导入所有 AppBundle 路由?

据我所知这是不可能的。阅读文档 How to Override any Part of a Bundle