假设我有两个捆绑包ParentBundle和ChildBundle. ChildBundle“扩展”ParentBundle为
// ChildBundle/ChildBundle.php
<?php
namespace ChildBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class ChildBundle extends Bundle
{
public function getParent()
{
return 'ParentBundle';
}
}
然后,我将路由从 复制ParentBundle到ChildBundle,并指定要在其中使用的路由,并根据Symfony2 捆绑继承丢失父捆绑路由app/config/routing.yml重命名routing.yml
// app/config/routing.yml
child:
resource: "@ChildBundle/Resources/config/routing_child.yml"
hostname_pattern: child.example.com
prefix: /
parent:
resource: "@ParentBundle/Resources/config/routing.yml"
prefix: /
之后,我创建了一个ChildBundle具有相同路径和名称的模板,以覆盖ParentBundle同名的模板。
但是,它会导致ChildBundle一直加载模板。
所以,我的问题是,我如何ChildBundle在一个域中加载(即使用覆盖模板/控制器等ChildBundle,当用户进入 child.example.com 时),同时ParentBundle在另一个域中使用(即使用覆盖模板/控制器等ParentBundle,当用户进入 example.com 时)?