Refactor form blocks to use composition instead of inheritance

[MAILPOET-2665]
This commit is contained in:
Rostislav Wolny
2020-02-10 14:32:39 +01:00
committed by Jack Kitterhing
parent 20926d56b7
commit c6ca749cdc
11 changed files with 138 additions and 68 deletions

View File

@@ -2,14 +2,21 @@
namespace MailPoet\Form\Block;
class Submit extends Base {
class Submit {
/** @var Base */
private $baseRenderer;
public function __construct(Base $baseRenderer) {
$this->baseRenderer = $baseRenderer;
}
public function render($block) {
$html = '';
$html .= '<p class="mailpoet_paragraph"><input type="submit" class="mailpoet_submit" ';
$html .= 'value="' . $this->getFieldLabel($block) . '" ';
$html .= 'value="' . $this->baseRenderer->getFieldLabel($block) . '" ';
$html .= 'data-automation-id="subscribe-submit-button" ';