2017-12-14 14:00:53 +01:00
|
|
|
<?php
|
|
|
|
namespace Saccas\Mjml\View;
|
|
|
|
|
2017-12-14 23:06:08 +01:00
|
|
|
use Saccas\Mjml\Domain\Renderer\RendererInterface;
|
2022-08-02 12:10:03 +02:00
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
2017-12-14 14:00:53 +01:00
|
|
|
use TYPO3\CMS\Fluid\View\StandaloneView;
|
2017-12-14 23:06:08 +01:00
|
|
|
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
|
2017-12-14 14:00:53 +01:00
|
|
|
|
|
|
|
class MjmlBasedView extends StandaloneView
|
|
|
|
{
|
2021-02-05 00:03:58 +01:00
|
|
|
protected ?RendererInterface $renderer = null;
|
2017-12-14 14:00:53 +01:00
|
|
|
|
2017-12-14 23:06:08 +01:00
|
|
|
public function __construct(ContentObjectRenderer $contentObject = null, RendererInterface $renderer = null)
|
2017-12-14 14:00:53 +01:00
|
|
|
{
|
2017-12-14 23:06:08 +01:00
|
|
|
parent::__construct($contentObject);
|
2017-12-14 14:00:53 +01:00
|
|
|
|
2017-12-14 23:06:08 +01:00
|
|
|
$this->renderer = $renderer;
|
|
|
|
if ($this->renderer === null) {
|
2022-08-19 11:13:06 +02:00
|
|
|
$this->renderer = GeneralUtility::makeInstance(RendererInterface::class);
|
2017-12-14 23:06:08 +01:00
|
|
|
}
|
2017-12-14 14:00:53 +01:00
|
|
|
}
|
2017-12-14 19:08:22 +01:00
|
|
|
|
2021-01-26 10:15:06 +01:00
|
|
|
public function render($actionName = null): string
|
2017-12-14 22:32:08 +01:00
|
|
|
{
|
2017-12-14 23:06:08 +01:00
|
|
|
return $this->renderer->getHtmlFromMjml(parent::render($actionName));
|
2017-12-14 19:08:22 +01:00
|
|
|
}
|
2017-12-14 14:00:53 +01:00
|
|
|
}
|