2017 © Pedro PelĂĄez
 

symfony-bundle contact-bundle

Symfony Th3MoukContactBundle to factorize contact form generation throught websites.

image

th3mouk/contact-bundle

Symfony Th3MoukContactBundle to factorize contact form generation throught websites.

  • Sunday, February 28, 2016
  • by Th3Mouk
  • Repository
  • 1 Watchers
  • 0 Stars
  • 217 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Contact Bundle

This Symfony bundle providing base for manage contact form., (*1)

The aim is to factorise website contact form., (*2)

SensioLabsInsight Latest Stable Version Total Downloads Build Status Latest Unstable Version License, (*3)

Installation

php composer.phar require th3mouk/contact-bundle ^1.2, (*4)

Add to the appKernel.php:, (*5)

new Th3Mouk\ContactBundle\Th3MoukContactBundle(),

Update your routing.yml application's file., (*6)

th3mouk_contact:
    resource: "@Th3MoukContactBundle/Resources/config/routing.yml"
    prefix:   /contact

Configure entities and templates in config.yml, (*7)

th3mouk_contact:
    datas:
        from: noreply@domain.com
        to:
            - test.mail@domain.com
        subject: Contact request from your website

    class:
        entity: AppBundle\Entity\Contact
        formType: AppBundle\Form\ContactType

    templates:
        application: AppBundle:Contact:contact.html.twig
        mailer: AppBundle:Contact:mail.html.twig

    flash_messages:
        success: contact.mail.success
        error: contact.mail.error

Usage

Create Contact entity that implement the Th3Mouk\ContactBundle\Entity\ContactInterface with the app/console d:g:entity., (*8)

Generate the relative FormType: app/console d:g:f AppBundle:Contact., (*9)

Create two template for frontend and mail, you have access to form object to draw your form, and your contact object in the mail template., (*10)

Check the following exemples:, (*11)

Exemple of ContactType

namespace AppBundle\Form;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ContactType extends AbstractType
{
    /**
     * @param FormBuilderInterface $builder
     * @param array                $options
     */
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name')
            ->add('adress')
            ->add('zipCode')
            ->add('city')
            ->add('phone')
            ->add('email', 'email')
            ->add('message')
        ;
    }

    /**
     * @param OptionsResolver $resolver
     */
    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'AppBundle\Entity\Contact',
        ));
    }

    /**
     * @return string
     */
    public function getName()
    {
        return 'app_contact_type';
    }
}

Exemple of Form Template



Contact Request

{{ form_start(form) }} {{ form_row(form.name) }} {{ form_row(form.adress) }} {{ form_row(form.zipCode) }} {{ form_row(form.city) }} {{ form_row(form.phone) }} {{ form_row(form.email) }} {{ form_row(form.message) }}
{{ form_rest(form) }} {{ form_end(form) }}

Exemple of Mail Template

{{ contact.name }}<br>
{{ contact.adress }}<br>
{{ contact.zipCode }}<br>
{{ contact.city }}<br>
{{ contact.phone }}<br>
{{ contact.email }}<br>
{{ contact.message }}

Sonata Integration Exemple

First use the app/console sonata:admin:generate command., (*12)

Then add the service configuration:, (*13)

app.admin.contact:
    class: AppBundle\Admin\ContactAdmin
    arguments: [~, AppBundle\Entity\Contact, SonataAdminBundle:CRUD]
    tags:
        - {name: sonata.admin, manager_type: orm, label: Contacts}

Add the admin group on the dashboard:, (*14)

sonata.admin.group.contact:
    label:           Contact
    label_catalogue: SonataPageBundle
    icon:            '<i class="fa fa-envelope"></i>'
    items:
        - app.admin.contact
    roles: [ ROLE_ADMIN ]

Don't forget to add this group on a block:, (*15)

sonata_admin:
    dashboard:
        blocks:
            - { position: left, type: sonata.admin.block.admin_list, settings: { groups: [...sonata.admin.group.contact...] }}

You're done! :+1:, (*16)

Events

You have access to two events before and after mail was send : * MailerEventsDefinition, (*17)

Please

Feel free to improve this bundle., (*18)

The Versions

28/02 2016

dev-master

9999999-dev

Symfony Th3MoukContactBundle to factorize contact form generation throught websites.

  Sources   Download

MIT

The Requires

 

by Jérémy Marodon

bundle symfony contact contact mailer

28/01 2016

1.2.0

1.2.0.0

Symfony Th3MoukContactBundle to factorize contact form generation throught websites.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Marodon

bundle symfony contact contact mailer

28/01 2016

dev-1.1-dev

dev-1.1-dev

Symfony Th3MoukContactBundle to factorize contact form generation throught websites.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Marodon

bundle symfony contact contact mailer

20/11 2015

1.1.2

1.1.2.0

Symfony Th3MoukContactBundle to factorize contact form generation throught websites.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Marodon

bundle symfony contact contact mailer

27/10 2015

1.1.1

1.1.1.0

Symfony Th3MoukContactBundle to factorize contact form generation throught websites.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Marodon

bundle symfony contact contact mailer

27/10 2015

1.1.0

1.1.0.0

Symfony Th3MoukContactBundle to factorize contact form generation throught websites.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Marodon

bundle symfony contact contact mailer

22/10 2015

dev-1.0-dev

dev-1.0-dev

Symfony Th3MoukContactBundle to factorise contact form generation throught websites.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Marodon

bundle symfony contact contact mailer

22/10 2015

1.0.1

1.0.1.0

Symfony Th3MoukContactBundle to factorise contact form generation throught websites.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jérémy Marodon

bundle symfony contact contact mailer

08/10 2015

1.0.0

1.0.0.0

Symfony Th3MoukContactBundle to factorise contact form generation throught websites.

  Sources   Download

MIT

The Requires

 

by Jérémy Marodon

bundle symfony contact contact mailer