"symfony/webpack-encore-bundle": "^1.11", | "symfony/webpack-encore-bundle": "^1.11", | ||||
"symfony/yaml": "5.2.*", | "symfony/yaml": "5.2.*", | ||||
"twig/extra-bundle": "^2.12|^3.0", | "twig/extra-bundle": "^2.12|^3.0", | ||||
"twig/twig": "^2.12|^3.0" | |||||
"twig/twig": "^2.12|^3.0", | |||||
"welp/mailchimp-bundle": "^1.3" | |||||
}, | }, | ||||
"require-dev": { | "require-dev": { | ||||
"symfony/browser-kit": "^5.2", | "symfony/browser-kit": "^5.2", |
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", | ||||
"This file is @generated automatically" | "This file is @generated automatically" | ||||
], | ], | ||||
"content-hash": "4f261c49c4e3d64b08acfca7246f15bf", | |||||
"content-hash": "cbf5b29748de791afdf10053f057e933", | |||||
"packages": [ | "packages": [ | ||||
{ | { | ||||
"name": "artgris/filemanager-bundle", | "name": "artgris/filemanager-bundle", | ||||
}, | }, | ||||
"time": "2021-01-08T14:18:52+00:00" | "time": "2021-01-08T14:18:52+00:00" | ||||
}, | }, | ||||
{ | |||||
"name": "drewm/mailchimp-api", | |||||
"version": "v2.5.4", | |||||
"source": { | |||||
"type": "git", | |||||
"url": "https://github.com/drewm/mailchimp-api.git", | |||||
"reference": "c6cdfab4ca6ddbc3b260913470bd0a4a5cb84c7a" | |||||
}, | |||||
"dist": { | |||||
"type": "zip", | |||||
"url": "https://api.github.com/repos/drewm/mailchimp-api/zipball/c6cdfab4ca6ddbc3b260913470bd0a4a5cb84c7a", | |||||
"reference": "c6cdfab4ca6ddbc3b260913470bd0a4a5cb84c7a", | |||||
"shasum": "" | |||||
}, | |||||
"require": { | |||||
"ext-curl": "*", | |||||
"ext-json": "*", | |||||
"php": ">=5.3" | |||||
}, | |||||
"require-dev": { | |||||
"phpunit/phpunit": "7.0.*", | |||||
"vlucas/phpdotenv": "^2.0" | |||||
}, | |||||
"type": "library", | |||||
"autoload": { | |||||
"psr-4": { | |||||
"DrewM\\MailChimp\\": "src" | |||||
} | |||||
}, | |||||
"notification-url": "https://packagist.org/downloads/", | |||||
"license": [ | |||||
"MIT" | |||||
], | |||||
"authors": [ | |||||
{ | |||||
"name": "Drew McLellan", | |||||
"email": "drew.mclellan@gmail.com", | |||||
"homepage": "http://allinthehead.com/" | |||||
} | |||||
], | |||||
"description": "Super-simple, minimum abstraction MailChimp API v3 wrapper", | |||||
"homepage": "https://github.com/drewm/mailchimp-api", | |||||
"support": { | |||||
"issues": "https://github.com/drewm/mailchimp-api/issues", | |||||
"source": "https://github.com/drewm/mailchimp-api/tree/master" | |||||
}, | |||||
"time": "2019-08-06T09:24:58+00:00" | |||||
}, | |||||
{ | { | ||||
"name": "easycorp/easyadmin-bundle", | "name": "easycorp/easyadmin-bundle", | ||||
"version": "v3.5.7", | "version": "v3.5.7", | ||||
"source": "https://github.com/webmozarts/assert/tree/1.10.0" | "source": "https://github.com/webmozarts/assert/tree/1.10.0" | ||||
}, | }, | ||||
"time": "2021-03-09T10:59:23+00:00" | "time": "2021-03-09T10:59:23+00:00" | ||||
}, | |||||
{ | |||||
"name": "welp/mailchimp-bundle", | |||||
"version": "1.3.2", | |||||
"source": { | |||||
"type": "git", | |||||
"url": "https://github.com/welpdev/mailchimp-bundle.git", | |||||
"reference": "a26617b03f02e5bee1061c63cc5b30c1e9719989" | |||||
}, | |||||
"dist": { | |||||
"type": "zip", | |||||
"url": "https://api.github.com/repos/welpdev/mailchimp-bundle/zipball/a26617b03f02e5bee1061c63cc5b30c1e9719989", | |||||
"reference": "a26617b03f02e5bee1061c63cc5b30c1e9719989", | |||||
"shasum": "" | |||||
}, | |||||
"require": { | |||||
"drewm/mailchimp-api": "2.5.*", | |||||
"php": ">=5.6" | |||||
}, | |||||
"require-dev": { | |||||
"phpspec/phpspec": "~2@dev", | |||||
"phpunit/phpunit": "~5", | |||||
"symfony/symfony": ">=2.7" | |||||
}, | |||||
"type": "symfony-bundle", | |||||
"autoload": { | |||||
"psr-4": { | |||||
"Welp\\MailchimpBundle\\": "src/" | |||||
} | |||||
}, | |||||
"notification-url": "https://packagist.org/downloads/", | |||||
"license": [ | |||||
"MIT" | |||||
], | |||||
"authors": [ | |||||
{ | |||||
"name": "Titouan BENOIT", | |||||
"email": "titouan@welp.today" | |||||
} | |||||
], | |||||
"description": "MailChimp API V3 Symfony Bundle", | |||||
"homepage": "https://github.com/welpdev/mailchimp-bundle", | |||||
"keywords": [ | |||||
"api", | |||||
"mailchimp", | |||||
"subscriber", | |||||
"symfony", | |||||
"user", | |||||
"v3" | |||||
], | |||||
"support": { | |||||
"issues": "https://github.com/welpdev/mailchimp-bundle/issues", | |||||
"source": "https://github.com/welpdev/mailchimp-bundle/tree/1.3.2" | |||||
}, | |||||
"time": "2021-08-06T15:16:21+00:00" | |||||
} | } | ||||
], | ], | ||||
"packages-dev": [ | "packages-dev": [ |
Lc\SovBundle\LcSovBundle::class => ['all' => true], | Lc\SovBundle\LcSovBundle::class => ['all' => true], | ||||
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], | Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true], | ||||
Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true], | Knp\Bundle\PaginatorBundle\KnpPaginatorBundle::class => ['all' => true], | ||||
Welp\MailchimpBundle\WelpMailchimpBundle::class => ['all' => true], | |||||
]; | ]; |
app_contribuate: | app_contribuate: | ||||
path: /contribution-individuel | path: /contribution-individuel | ||||
controller: App\Controller\Frontend\ContribuateController::contribuate | |||||
controller: App\Controller\Frontend\ContribuateController::contribuate | |||||
app_newsletter_subscribe: | |||||
path: /newsletter/inscription | |||||
controller: App\Controller\Frontend\NewsletterController::subscribeNewsletter |
resource: '../src/Controller/' | resource: '../src/Controller/' | ||||
tags: ['controller.service_arguments'] | tags: ['controller.service_arguments'] | ||||
welp_mailchimp: | |||||
api_key: 86a597a26c06a1896fe0adc58d1e8aef-us2 |
<?php | |||||
namespace App\Controller\Frontend; | |||||
use App\Form\SubscribeNewsletterForm; | |||||
use Symfony\Component\HttpFoundation\Request; | |||||
use Welp\MailchimpBundle\Exception\MailchimpException; | |||||
use Welp\MailchimpBundle\Event\SubscriberEvent; | |||||
use Welp\MailchimpBundle\Subscriber\Subscriber; | |||||
class NewsletterController extends DefaultController | |||||
{ | |||||
public function subscribeNewsletter(Request $request) | |||||
{ | |||||
$form = $this->createForm(SubscribeNewsletterForm::class) ; | |||||
$form->handleRequest($request) ; | |||||
if($form->isSubmitted() && $form->isValid()) { | |||||
$data = $form->getData() ; | |||||
$email = $data['email'] ; | |||||
try { | |||||
// api mailchimp | |||||
$subscriber = new Subscriber($email); | |||||
$this->container->get('event_dispatcher')->dispatch( | |||||
SubscriberEvent::EVENT_SUBSCRIBE, | |||||
new SubscriberEvent('91a235f34c', $subscriber) | |||||
); | |||||
$this->addFlash('success', 'Votre inscription à notre newsletter a bien été prise en compte.'); | |||||
} | |||||
catch(MailchimpException $exception) { | |||||
$this->addFlash('error', $exception->getMessage()); | |||||
} | |||||
} | |||||
return $this->redirectToRoute('home') ; | |||||
} | |||||
} |
<?php | |||||
namespace App\Form; | |||||
use Symfony\Component\Form\AbstractType; | |||||
use Symfony\Component\Form\Extension\Core\Type\EmailType; | |||||
use Symfony\Component\Form\FormBuilderInterface; | |||||
use Symfony\Component\OptionsResolver\OptionsResolver; | |||||
class SubscribeNewsletterForm extends AbstractType | |||||
{ | |||||
/** | |||||
* @param FormBuilderInterface $builder | |||||
* @param array $options | |||||
*/ | |||||
public function buildForm(FormBuilderInterface $builder, array $options) | |||||
{ | |||||
parent::buildForm($builder, $options); | |||||
$builder | |||||
->add('email', EmailType::class, [ | |||||
'label' => 'Email', | |||||
'attr' => [ | |||||
'placeholder' => 'Email' | |||||
] | |||||
]); | |||||
} | |||||
/** | |||||
* @param OptionsResolver $resolver | |||||
*/ | |||||
public function setDefaultOptions(OptionsResolver $resolver) | |||||
{ | |||||
$resolver->setDefaults( | |||||
[ | |||||
] | |||||
); | |||||
} | |||||
/** | |||||
* @return string | |||||
*/ | |||||
public function getName() | |||||
{ | |||||
return 'subscribe_newsletter'; | |||||
} | |||||
} |
"dompdf/dompdf": { | "dompdf/dompdf": { | ||||
"version": "v1.0.2" | "version": "v1.0.2" | ||||
}, | }, | ||||
"drewm/mailchimp-api": { | |||||
"version": "v2.5.4" | |||||
}, | |||||
"easycorp/easyadmin-bundle": { | "easycorp/easyadmin-bundle": { | ||||
"version": "3.0", | "version": "3.0", | ||||
"recipe": { | "recipe": { | ||||
}, | }, | ||||
"webmozart/assert": { | "webmozart/assert": { | ||||
"version": "1.10.0" | "version": "1.10.0" | ||||
}, | |||||
"welp/mailchimp-bundle": { | |||||
"version": "1.3.2" | |||||
} | } | ||||
} | } |