如何重命名symfony中的包? [英] How to rename a bundle in symfony?

查看:68
本文介绍了如何重命名symfony中的包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的捆绑软件位于 src / Cinergy / Bundle / ComponentBundle / CinergyComponentBundle.php ,捆绑软件的逻辑名称为'CinergyComponentBundle'

My bundle is located at src/Cinergy/Bundle/ComponentBundle/CinergyComponentBundle.php and the logical name of the bundle is 'CinergyComponentBundle'.

由于我没有遵守公司的命名约定,因此必须更改捆绑商品的逻辑名称。假设我必须将其重命名为'XXXCinergyComponentBundle'

Since I did not stick to the naming convention of the company I have to change the logcial name of the bundle. Lets asume I have to rename it to 'XXXCinergyComponentBundle'

我需要更改哪些文件?

我尝试将 CinergyComponentBundle.php 文件和包含的类重命名为 XXXCinergyComponentBundle.php 。我还更改了AppKernel中的引用。

I tried renaming the CinergyComponentBundle.php file and the containing class into XXXCinergyComponentBundle.php. I also changed the reference in AppKernel.

不幸的是,这不起作用。当我尝试清除缓存时,出现以下错误消息:

Unfortunately this does not work. When I try to clear the cache I get this error message:

[Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]                                   
The service "cinergy.people.direct.php" has a dependency on a non-existent service "cinergy.work.registry". 

这两个服务确实属于具有新名称的捆绑包。这使我得出的结论是,我在重命名过程中丢失了某些内容。

This two services do belong to the bundle with the new name. This leads me to the conclusion that I'm missing something in the renaming process.

有任何想法吗?

推荐答案

我刚刚完成了自己的重命名,结果和几分钟前一样。至此,我已经使用了编辑器的replace-function。事实证明,有些文件需要特别注意,位于此处(假设您的旧捆绑包名称为AcmeOldBundle,新的捆绑包名称为AcmeNewBundle):

I have just completed renaming a bundle myself and ended up at the exact same point as you did a couple of minutes ago. To this point I have used my editors replace-function. It turns out there are some files that need some extra care, which are located here (assuming your old Bundle name was AcmeOldBundle, new will be AcmeNewBundle):


  1. Acme\OldBundle\OldBundle.php-> NewBundle.php

  2. Acme\OldBundle\DependencyInjection\AcmeOldExtension.php->
    AcmeNewExtension.php

不要忘记同时更新文件中的类名。

Do not forget to update the class-names inside the files as well.

这篇关于如何重命名symfony中的包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆