kphoen/contact-bundle

该包已被 废弃,不再维护。没有建议的替代包。

又一个联系包

安装次数: 2,706

依赖项: 0

建议者: 0

安全: 0

星标: 7

关注者: 5

分支: 4

开放问题: 0

类型:symfony-bundle

4.0.0 2016-12-28 15:15 UTC

This package is auto-updated.

Last update: 2022-01-27 19:59:54 UTC


README

Build Status StyleCI Coverage Status Latest stable release Overall downloads on Packagist license

又一个联系包。

安装

Composer

kphoen/contact-bundle 添加到所需字段。然后安装/更新依赖项。

app/AppKernel.php

注册 KPhoenContactBundle

# app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new KPhoen\ContactBundle\KPhoenContactBundle(),
    );
}

配置

config.yml

app/config/config.yml 文件中提供了以下选项

k_phoen_contact:
    redirect_url:       homepage  # the url to redirect the user to once the
                                  # mail is sent
    sender:             { address: 'no-reply@foo.org' }
    receiver:           { address: 'contact@foo.org' }

路由

导入路由

kphoen_contact:
    resource: "@KPhoenContactBundle/Resources/config/routing.yml"

使用

路由

前面的配置导入了名为 contact 的路由,它对应一个简单的联系表单。

模板

你可能需要自定义该包使用的视图。为此,我们将覆盖联系包公开的模板。

app/Resources/KPhoenContactBundle/views/Contact/contact.html.twig

{% extends 'AcmeDemoBundle::layout.html.twig' %}

{% block title %}Contact{% endblock %}

{% block body %}
<h2>Contact</h2>

{% include "KPhoenContactBundle:Contact:form.html.twig" with {'form': form} %}
{% endblock %}

事件

在表单提交过程中会发出两个事件

  • contact.pre_send: 在邮件发送前发出;
  • contact.post_send: 在之后发出。

贡献

查看 CONTRIBUTING 文件。