MailchimpListsClearCacheForm.php in Mailchimp 8
File
modules/mailchimp_lists/src/Form/MailchimpListsClearCacheForm.php
View source
<?php
namespace Drupal\mailchimp_lists\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
class MailchimpListsClearCacheForm extends ConfirmFormBase {
protected $messenger;
public function __construct(MessengerInterface $messenger) {
$this->messenger = $messenger;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('messenger'));
}
public function getFormId() {
return 'mailchimp_lists_admin_clear_cache';
}
protected function getEditableConfigNames() {
return [
'mailchimp_lists.clear_cache',
];
}
public function getQuestion() {
return $this
->t('Reset Mailchimp Audience Cache');
}
public function getCancelUrl() {
return Url::fromRoute('mailchimp_lists.overview');
}
public function getDescription() {
return $this
->t('Confirm clearing of Mailchimp audience cache.');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
mailchimp_get_lists([], TRUE);
$this->messenger
->addStatus($this
->t('Mailchimp audience cache cleared.'));
}
}