frequence-web / contact-bundle
Event-based contact bundle
Installs: 12 216
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 5
Forks: 8
Open Issues: 4
Type:symfony-bundle
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
An event-based Symfony2 Contact Bundle.
Installation
Install the bundle via composer
$ composer require frequence-web/contact-bundle:1.0.*
Add the bundle to your AppKernel
class
public function registerBundles() { return array( // ... Your bundles new \FrequenceWeb\Bundle\ContactBundle\FrequenceWebContactBundle(), ); }
Configuration
This bundle provides some configuration options :
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
Routing
If you want to use the default bundle urls, just import the routing file in your application routing:
_frequence_web_contact: resource: '@FrequenceWebContactBundle/Resources/config/routing.xml'
This will create 2 routes, with the same URL (/contact.html), one for displaying the contact form (GET), the other to submit data (POST)
Creating Listener
If you want to make a more featured mail listener, or any other listener, you have to define your own.
The dispatched event on success contact form submit is contact.submit
, and receive a
FrequenceWeb\Bundle\ContactBundle\EventDispatcher\Event\MessageSubmitEvent
.
If you need an example, juste have a look to
FrequenceWeb\Bundle\ContactBundle\EventDispatcher\Listener\EmailContactListener
.
Extending
If you need more datas that the few ones provided by the Contact
class and the ContactType
form type, just
override the frequence_web_contact.type.class
and frequence_web_contact.model.class
configuration parameters,
they are used to instantiate services and can be extended without any limit.