Add qferr/mjml-php v2.0.0 compatibility

This commit is contained in:
grandeljay 2022-11-28 11:30:13 +01:00
parent 9a84424791
commit 82e4b4c249

View file

@ -12,8 +12,6 @@
namespace wishthis; namespace wishthis;
use Qferrer\Mjml\Renderer\ApiRenderer;
class Email class Email
{ {
private string $mjml = ''; private string $mjml = '';
@ -46,21 +44,23 @@ class Email
{ {
global $options; global $options;
$renderer = new ApiRenderer( $api = new \Qferrer\Mjml\Http\CurlApi(
$options->getOption('mjml_api_application_id'), $options->getOption('mjml_api_application_id'),
$options->getOption('mjml_api_secret_key') $options->getOption('mjml_api_secret_key')
); );
$renderer = new \Qferrer\Mjml\Renderer\ApiRenderer($api);
$html = $this->mjml; $html = $this->mjml;
if (defined('ENV_IS_DEV') && ENV_IS_DEV) { if ('127.0.0.1' === $_SERVER['REMOTE_ADDR']) {
/** /**
* Ignore SSL certificate errors * Ignore SSL certificate errors
*/ */
try { try {
$html = $renderer->render($this->mjml); $html = $renderer->render($this->mjml);
} catch (\GuzzleHttp\Exception\RequestException $th) { } catch (\Qferrer\Mjml\Exception\CurlException $th) {
error_log($th->getMessage()); error_log($th->getMessage());
error_log($this->mjml);
} }
} else { } else {
$html = $renderer->render($this->mjml); $html = $renderer->render($this->mjml);