frequence-web / contact-bundle
基于事件的联系组件
1.0.4
2017-05-23 10:06 UTC
Requires
- php: ^5.3.3 || ^7.0
- symfony/form: ~2.8 || ^3.0
- symfony/framework-bundle: ~2.8 || ^3.0
- symfony/twig-bundle: ~2.8 || ^3.0
- symfony/validator: ~2.8 || ^3.0
Requires (Dev)
- phpunit/phpunit: ^3.0
- symfony/browser-kit: ~2.1 || ^3.0
- symfony/class-loader: ~2.1 || ^3.0
- symfony/css-selector: ~2.1 || ^3.0
- symfony/dom-crawler: ~2.1 || ^3.0
- symfony/finder: ~2.1 || ^3.0
- symfony/swiftmailer-bundle: ~2.1 || ^2.5
Suggests
- symfony/swiftmailer-bundle: If your want to use the (default) mail listener.
README
一个基于事件的 Symfony2 联系组件。
安装
使用 composer 安装组件
$ composer require frequence-web/contact-bundle:1.0.*
将组件添加到您的 AppKernel
类中
public function registerBundles() { return array( // ... Your bundles new \FrequenceWeb\Bundle\ContactBundle\FrequenceWebContactBundle(), ); }
配置
此组件提供了一些配置选项
frequence_web_contact: send_mails: true # True to use the bundle EmailListener that send emails when contact form is submited to: null # The contact mail recipient from: null # The contact mail sender subject: contact.message.new # The contact mail subject translation key
路由
如果您想使用默认的组件 URL,只需将路由文件导入到应用程序的路由中
_frequence_web_contact: resource: '@FrequenceWebContactBundle/Resources/config/routing.xml'
这将创建 2 个路由,具有相同的 URL (/contact.html),一个用于显示联系表单(GET),另一个用于提交数据(POST)
创建监听器
如果您想创建一个功能更强大的邮件监听器或其他监听器,您需要定义自己的。成功提交联系表单时触发的事件是 contact.submit
,并接收一个 FrequenceWeb\Bundle\ContactBundle\EventDispatcher\Event\MessageSubmitEvent
。
如果您需要一个示例,请查看 FrequenceWeb\Bundle\ContactBundle\EventDispatcher\Listener\EmailContactListener
。
扩展
如果您需要更多由 Contact
类和 ContactType
表单类型提供的少量数据,只需覆盖 frequence_web_contact.type.class
和 frequence_web_contact.model.class
配置参数,它们用于实例化服务,并且可以无限制地扩展。