You've already forked grav-plugin-listmonk
use local version of listmonk-php
This commit is contained in:
63
listmonk.php
63
listmonk.php
@@ -8,7 +8,6 @@ use Grav\Common\Data\Data;
|
||||
use Grav\Common\Plugin;
|
||||
use Grav\Plugin\Form\Form;
|
||||
use Grav\Plugin\Listmonk\Exceptions\ListmonkClientException;
|
||||
use Grav\Plugin\Listmonk\Exceptions\ListmonkException;
|
||||
use RocketTheme\Toolbox\Event\Event;
|
||||
use ValueError;
|
||||
|
||||
@@ -83,14 +82,15 @@ class ListmonkPlugin extends Plugin
|
||||
$this->processNewsletterForm($event, $form, $this->getParams($form, $params));
|
||||
break;
|
||||
|
||||
#case 'listmonk':
|
||||
# $this->processForm($event, $form, $this->getParams($form, $params));
|
||||
# break;
|
||||
}#
|
||||
case 'listmonk_transactional':
|
||||
$this->processTransactionalForm($event, $form, $this->getParams($form, $params));
|
||||
break;
|
||||
}
|
||||
$event->stopPropagation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process `listmonk_newsletter` form action
|
||||
* Store a newsletter subscriber in listmonk
|
||||
*
|
||||
* @param Event $event
|
||||
* @return void
|
||||
@@ -125,10 +125,36 @@ class ListmonkPlugin extends Plugin
|
||||
'form' => $form,
|
||||
'message' => $this->parseMessage($e->getMessage())
|
||||
]));
|
||||
$event->stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a transactional mail using listmonk
|
||||
*
|
||||
* (Not implemented yet!)
|
||||
*
|
||||
* @param Event $event
|
||||
* @return void
|
||||
*/
|
||||
private function processTransactionalForm(Event $event, Form $form, array $params): void
|
||||
{
|
||||
$this->grav->fireEvent('onFormValidationError', new Event([
|
||||
'form' => $form,
|
||||
'message' => 'Sending transactional emails is not implemented yet',
|
||||
]));
|
||||
|
||||
#try {
|
||||
# $client = $this->getListmonkClient();
|
||||
#} catch (ListmonkClientException $e) {
|
||||
# $this->grav->fireEvent('onFormValidationError', new Event([
|
||||
# 'form' => $form,
|
||||
# 'message' => $e->getMessage(),
|
||||
# ]));
|
||||
#} catch (ListmonkException $e) {
|
||||
# throw new \RuntimeException('Error while processing form', -1, $e);
|
||||
#}
|
||||
}
|
||||
|
||||
private function processAttributes(array $attributes): array
|
||||
{
|
||||
$globals = $this->config->get('plugins.listmonk.newsletter.subscriber.attributes');
|
||||
@@ -160,29 +186,6 @@ class ListmonkPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process `listmonk` form action
|
||||
*
|
||||
* @param Event $event
|
||||
* @return void
|
||||
*/
|
||||
private function processForm(Event $event, Form $form, array $params): void
|
||||
{
|
||||
try {
|
||||
$client = $this->getListmonkClient();
|
||||
|
||||
} catch (ListmonkClientException $e) {
|
||||
$this->grav->fireEvent('onFormValidationError', new Event([
|
||||
'form' => $form,
|
||||
'message' => $e->getMessage()
|
||||
]));
|
||||
$event->stopPropagation();
|
||||
} catch (ListmonkException $e) {
|
||||
$event->stopPropagation();
|
||||
throw new \RuntimeException('Error while processing form', -1, $e);
|
||||
}
|
||||
}
|
||||
|
||||
private function getListmonkClient(): ListMonk
|
||||
{
|
||||
if ($this->client instanceof ListMonk) {
|
||||
|
||||
Reference in New Issue
Block a user