imocontrol / m3-extension-bundle
iMOControl 扩展包帮助构建
Requires
- php: >=5.3.2
- symfony/console: ~2
- symfony/finder: ~2
- symfony/framework-bundle: ~2
This package is not auto-updated.
Last update: 2024-09-23 14:18:23 UTC
README
此包是从由 Thomas Rabaix 开发的 Sonata-Easy-Extends-Bundle 拷贝的。由 Michael Ofner 进行定制,以便从每个 iMOControl Bundle 生成有效的应用包结构。使用这个小工具,应该很容易使所有核心包可扩展。
安装
将 imocontrol/m3-extenstion-bundle 添加到您的 composer.json 或执行以下命令
$ php composer.phar require imocontrol/m3-extenstion-bundle
接下来,请确保将以下行添加到您的 AppKernel
<?php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new IMOControl\M3\ExtensionBundle\IMOControlM3ExtensionBundle(),
// ...
);
}
现在包已准备好使用。
用法
安装后,您可以将每个 iMOControlBundle 扩展为生成一个应用程序包,您可以按需求对其进行定制。
神奇命令是
$ php app/console imocontrol:extension:generate IMOControlM3CustomerBundle
此命令将在 src/ 中生成新的 ApplicationIMOControlM3CustomerBundle。您可以通过使用 --dest=your/custom/folder 参数更改目标位置。
之后,将 ApplicationIMOControlM3CustomerBundle 添加到您的 AppKernel。
<?php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Application\IMOControl\M3\CustomerBundle\IMOControlM3CustomerBundle(),
// ...
);
}
最后但同样重要的是,我们必须告诉 iMOControl 使用新的应用程序包。
# app/config/imocontrol/customer.yml
imo_control_m3_customer:
customer_folder_root_dir: "%kernel.root_dir%/data/customers/"
class:
project: Application\IMOControl\M3\ProjectBundle\Entity\Project
invoice: IMOControl\M3\InvoiceBundle\Entity\Invoice
admin:
customer:
class: Application\IMOControl\M3\CustomerBundle\Admin\CustomerAdmin
entity: IMOControl\M3\CustomerBundle\Entity\Customer
controller: IMOControlM3CustomerBundle:Default
translation: default
contact:
class: Application\IMOControl\M3\CustomerBundle\Admin\ContactAdmin
entity: IMOControl\M3\CustomerBundle\Entity\Contact
controller: IMOControlM3CustomerBundle:Default
translation: default
customer_address:
class: Application\IMOControl\M3\CustomerBundle\Admin\CustomerAddressAdmin
entity: IMOControl\M3\CustomerBundle\Entity\CustomerAddress
controller: IMOControlM3CustomerBundle:Default
translation: default
如您在上述配置中看到的那样,每个 AdminClass、Entity、Controller 和 Config 都可以在其 ApplicationBundle 中进行更改。
更多信息
有关更多信息,您可以阅读 SonataEasyExtendsBundle 的原始文档 http://sonata-project.org/bundles/easy-extends/master/doc/index.html。