thewellcom/contact-bundle

使用此扩展包轻松制作联系表单

安装: 63

依赖项: 0

建议者: 0

安全: 0

星级: 1

关注者: 2

分支: 1

开放问题: 0

类型:symfony-bundle

1.1.1 2016-06-18 19:15 UTC

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 }