Giter Club home page Giter Club logo

contactbundle's Introduction

Provides a simple but powerful contact form built onto the Observer Pattern. Plug any listener you want to your contact form's submission

Todo

  • Add mongodb configuration files
  • Add unit tests
  • Comment methods and attributes
  • Cleanup

(Quite the same as for GithubBundle, we are sorry for that methodology but we'll correct that soon).

Features

  • Compatible with Doctrine ORM and ODM thanks to a generic repository.
  • Model is extensible at will
  • Observer Pattern designed for more flexibility
  • Every class is customizable

Installation

Using submodules If you prefer instead to use git submodules, the run the following:

$ git submodule add git://github.com/ihqs/ContactBundle.git    src/IHQS/ContactBundle

Using the vendors script

Add the following lines in your deps file:

[IHQSContactBundle]
    git=git://github.com/ihqs/ContactBundle.git
    target=bundles/IHQS/ContactBundle

If you want to connect the email listener, install SwitfMailer and configure it

$ git submodule add git://github.com/swiftmailer.git    src/vendor/swiftmailer

or via deps file

[swiftmailer]
    git=http://github.com/swiftmailer/swiftmailer.git
    version=v4.1.2

In your config, add :

swiftmailer.config:
    transport:  smtp
    encryption: ssl
    auth_mode:  login
    host:       domain.tld
    username:   [email protected]
    password:   your_secret

Add the IHQS namespace to your autoloader

// app/autoload.php
$loader->registerNamespaces(array(
    'IHQS' => __DIR__.'/../vendor/bundles',
    // your other namespaces
);

Add ContactBundle to your application kernel

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new IHQS\ContactBundle\IHQSContactBundle(),
        // ...
    );
}

Update your schema

app/console doctrine:schema:update --force

Adding the form to your templates

In your template, you just have to add (if you are using Twig)

{% render "IHQSContactBundle:Contact:form" with { 'method': app.request.method }, { 'query': app.request.request.all } %}

Since version 2.0.13 of Symfony you must send your form "POST" data using "query" parameter. That's because "render" tag is being processed as a sub-request. And since that version all sub-requests are forced to use "GET" method therefore your embedded ContactController will loose all "POST" data if you miss it. As well you should explicitly specify the request method in "method" parameter to let the embedded ContactController recognize that your form is submitted.

Configuration

In your app/config.yml (given you are using YAML for your configuration file)

ihqs_contact:
    contact:
        form:
            type:               ihqs_contact_contact
            handler:            ihqs_contact.contact.form.handler.default
            name:               ihqs_contact_contact_form
            validation_groups:  [Contact]
    form: ~                                 # (optional) class managing the contact form
    model: ~                                # (optional) class managing the model
    connectors:                             # the list of "listeners" (or connectors here)
        email:                              # connecting the email listener
            recipients: [email protected]    # giving him the recipient(s) email(s)
        database:                           # connecting the database listener
            db_driver: orm                  # giving him the database driver
        file: ~                             # connecting the file logger listener

If you want a simple contact form only sending an email to you contact mailbox, then you just have to add to your configuration file

ihqs_contact:
    connectors:
        email:
            recipients: [email protected]

It you want to use a custom template/view instead of the default one (IHQSContactBundle:Contact:form.html.twig), you can add the view parameter with the name of your view. Example:

ihqs_contact:
    contact:
        form:
			view:               CompanyExampleBundle:Contact:form.html.twig

Using Akismet for Spam Detection

skip the step if you dont want to check for spam, by default no spam will be detected. Install the OrnicarAkismentBundle and configure it properly. see the docs for more information.

define the service in your service container

ihqs_contact:
    spam_detector:
        service: ornicar_akismet

now all your Contact Request will be checked by Akismet.

if you want to implement your own Detector simply set the class for the detector

ihqs_contact:
    spam_detector:
        class: My\Bundle\MyDetector

note that the class should implement the SpamDetectorInterface

or if you want a whole new service:

ihqs_contact:
    spam_detector:
        service: my_detector_service

contactbundle's People

Contributors

aleph-fr avatar bieleke avatar digitalkaoz avatar hostingnuggets avatar mente avatar mik356ua avatar pentarim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

contactbundle's Issues

Best way to use captcha ?

Hi Folks,

I have installed the greg captcha bundle, what is the best way to implement that into the form ?

After installing sonata admin and fos userbundle

An exception has been thrown during the rendering of a template ("Class IHQS\ContactBundle\Entity\Contact is not a valid entity or mapped super class.") in TorpedosWelcomeBundle:Default:contact.html.twig at line 9

???

Can anybody explain ?

ScopeWideningInjectionException when configuring spam detection

Hi, I'm trying to configure spam detection with OrnicarAkismetBundle according to the ContactBundle documentation, but I receive the following error:

ScopeWideningInjectionException: Scope Widening Injection detected: The definition "ihqs_contact.connectors.database.event_listener" references the service "ornicar_akismet.akismet_real" which belongs to a narrower scope. Generally, it is safer to either move "ihqs_contact.connectors.database.event_listener" to scope "request" or alternatively rely on the provider pattern by injecting the container itself, and requesting the service "ornicar_akismet.akismet_real" each time it is needed. In rare, special cases however that might not be necessary, then you can set the reference to strict=false to get rid of this error.

I'm using Symfony 2.0.17 and OrnicarAkismetBundle master.

I've searched for solutions, but could do with some pointers/advice on resolving this issue.

Thanks

Simple form doesn't work.

If you want a simple contact form only sending an email to you contact mailbox, then you just have to add to your configuration file

ihqs_contact:
connectors:
email:
recipients: [email protected]

This doesn't work, produces the next error...

Whoops, looks like something went wrong.
1/1 ErrorException: Notice: Undefined index: contact in /var/www/vendor/bundles/IHQS/ContactBundle/DependencyInjection/IHQSContactExtension.php line 44

in /var/www/vendor/symfony/src/Symfony/Component/HttpKernel/Debug/ErrorHandler.php line 65
at ErrorHandler->handle() in /var/www/vendor/bundles/IHQS/ContactBundle/DependencyInjection/IHQSContactExtension.php line 44
at IHQSContactExtension->load() in /var/www/vendor/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php line 42
at MergeExtensionConfigurationPass->process() in /var/www/vendor/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php line 39
at MergeExtensionConfigurationPass->process() in /var/www/vendor/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php line 119
at Compiler->compile() in /var/www/vendor/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php line 437
at ContainerBuilder->compile() in /var/www/app/bootstrap.php.cache line 868
at Kernel->buildContainer() in /var/www/app/bootstrap.php.cache line 779
at Kernel->initializeContainer() in /var/www/app/bootstrap.php.cache line 513
at Kernel->boot() in /var/www/app/bootstrap.php.cache line 544
at Kernel->handle() in /var/www/html/app_dev.php line 33

However if i use the extended version of the config this error does not happen.

How to install on symfony 2.1 ?

"ihqs/ContactBundle": "*"

Seems not to work out.

php composer.phar update IHQS/ContactBundle

Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package ihqs/contactbundle * could not be found.

Potential causes:

So what should it be for symfony 2.1 ?

Error after adding doctrine_mongodb

I recently started using the ContactBundle. Worked fine until I added a config for doctrine_mongodb: alongside doctrine:

Notice: Undefined index: IHQS\ContactBundle\Document\Contact in vendor\doctrine-mongodb-odm\lib\Doctrine\ODM\MongoDB\Mapping\Driver\AbstractFileDriver.php line 116 

We are using both MySQL as well as Mongo.

Seems like the bundle is trying to use Mongo even though I am not using a database connector.

  contact:
      form:
          type:               ihqs_contact_contact
          handler:            ihqs_contact.contact.form.handler.default
          name:               ihqs_contact_contact_form
          validation_groups:  [Contact]
  connectors:
      email:
         recipients: [email protected]

Apologies for the newbie-ish question.

Out of date

This bundle is not compatible with Symfony 2.0 stable release.
Multiples issues in controlleur, template, etc.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.