thewellcom /contact-bundle
使用此扩展包轻松制作联系表单
1.1.1
2016-06-18 19:15 UTC
Requires
- php: >=5.3.9
- friendsofsymfony/jsrouting-bundle: ^1.6
This package is not auto-updated.
Last update: 2024-09-23 13:11:20 UTC
README
配置
在 app/AppKernel.php 中
class AppKernel extends Kernel
{
...
public function registerBundles()
{
...
new TheWellCom\ContactBundle\TheWellComContactBundle(),
...
}
}
您需要创建自己的 ContactBundle。
并在 YourProjectContactBundle.php
中
namespace YourProject\Bundle\ContactBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class YourProjectContactBundle extends Bundle
{
public function getParent()
{
return 'TheWellComContactBundle';
}
}
创建实体 Contact
并在 YourProject\Bundle\ContactBundle\Entity\Contact.php
中
<?php
namespace TM\Bundle\ContactBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use TheWellCom\ContactBundle\Model\Contact as BaseContact;
/**
* Contact.
*
* @ORM\Table(name="contact")
* @ORM\Entity
*/
class Contact extends BaseContact
{
...
}
在 app/config/config.yml 中
the_well_com_contact:
mail_to: 'xy@domainname.com'
site_name: 'Your site name'
entity_class: 'YourProject\Bundle\ContactBundle\Entity\Contact'
在 app/config/routing.yml 中
the_well_com_contact:
resource: "@TheWellComContactBundle/Resources/config/routing.yml"
使用 sonataAdminBundle 进行管理
您需要安装 sonataAdminBundle: https://github.com/sonata-project/SonataAdminBundle
ContactAdmin.php
如果您需要添加管理员,只需在您的 ContactAdmin.php
中添加即可
namespace YourProject\Bundle\ContactBundle\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use TheWellCom\ContactBundle\Admin\ContactAdmin as BaseAdmin;
class ContactAdmin extends BaseAdmin
{
...
}
service.yml
在您的 service.yml
文件中添加
services:
admin.contact:
class: YourProject\Bundle\ContactBundle\Admin\ContactAdmin
arguments: [~, YourProject\Bundle\ContactBundle\Entity\Contact, ~]
tags:
- { name: sonata.admin, manager_type: orm, label: Contact }