drt5813 2016-05-23 11:54
浏览 63
已采纳

用于覆盖文件的Symfony Bundle名称

When extending/overriding a Bundle in a Symfony (3.0.x) project one adds the according folder to the "/app/Resources" folder. I got that. What I did not get is how you know which name that folder should have.

Example: The FOSUserBundle wants a folder named "FOSUserBundle". The location of the bundle is "/vendor/friendsofsymfony/user-bundle/".

Obviously this is not the same name as the folder in the app/Resources location gets.

Where do I find the name or mapping information of a bundle that defines how to call the folder to be added? Thank you in advance!

  • 写回答

3条回答 默认 最新

  • douyousu9691 2016-05-23 12:15
    关注

    The bundle name is the short class name (the final part of the class name without the namespace) of the actual bundle class (see the code).

    A few examples..

    FOS\UserBundle\FOSUserBundle                  -> FOSUserBundle
    Sylius\Bundle\ReviewBundle\SyliusReviewBundle -> SyliusReviewBundle
    Sonata\BlockBundle\SonataBlockBundle          -> SonataBlockBundle
    

    If you look at the class you use to add a bundle to your registered bundles you can get the bundle name from that.

    So, for example (taken from the Sonata Block Bundle docs)..

    public function registerBundles()
    {
        return array(
            // Dependency (check that you don't already have this line)
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
    
            // Vendor specifics bundles
            new Sonata\CoreBundle\SonataCoreBundle(),
            new Sonata\BlockBundle\SonataBlockBundle(),
        );
    }
    

    would be KnpMenuBundle, SonataCoreBundle and SonataBlockBundle.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘