Extract rendering of a single block to extra class

[MAILPOET-2665]
This commit is contained in:
Rostislav Wolny
2020-01-29 16:56:13 +01:00
committed by Jack Kitterhing
parent a759530b9d
commit d9b9e13a04
4 changed files with 64 additions and 50 deletions

View File

@ -0,0 +1,51 @@
<?php
namespace MailPoet\Form;
class BlocksRenderer {
public function renderBlock(array $block = []): string {
$html = '';
switch ($block['type']) {
case 'html':
$html .= Block\Html::render($block);
break;
case 'divider':
$html .= Block\Divider::render();
break;
case 'checkbox':
$html .= Block\Checkbox::render($block);
break;
case 'radio':
$html .= Block\Radio::render($block);
break;
case 'segment':
$html .= Block\Segment::render($block);
break;
case 'date':
$html .= Block\Date::render($block);
break;
case 'select':
$html .= Block\Select::render($block);
break;
case 'text':
$html .= Block\Text::render($block);
break;
case 'textarea':
$html .= Block\Textarea::render($block);
break;
case 'submit':
$html .= Block\Submit::render($block);
break;
}
return $html;
}
}