mjml-typo3/Classes/View/MjmlBasedView.php

30 lines
786 B
PHP
Raw Permalink Normal View History

2017-12-14 14:00:53 +01:00
<?php
namespace Saccas\Mjml\View;
use Saccas\Mjml\Domain\Renderer\RendererInterface;
2017-12-14 14:00:53 +01:00
use TYPO3\CMS\Fluid\View\StandaloneView;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
2017-12-14 14:00:53 +01:00
class MjmlBasedView extends StandaloneView
{
/**
* @var RendererInterface
*/
protected $renderer;
2017-12-14 14:00:53 +01:00
public function __construct(ContentObjectRenderer $contentObject = null, RendererInterface $renderer = null)
2017-12-14 14:00:53 +01:00
{
parent::__construct($contentObject);
2017-12-14 14:00:53 +01:00
$this->renderer = $renderer;
if ($this->renderer === null) {
$this->renderer = $this->objectManager->get(RendererInterface::class);
}
2017-12-14 14:00:53 +01:00
}
2017-12-14 19:08:22 +01:00
public function render($actionName = null)
{
return $this->renderer->getHtmlFromMjml(parent::render($actionName));
2017-12-14 19:08:22 +01:00
}
2017-12-14 14:00:53 +01:00
}