checkbox = $checkbox; $this->column = $column; $this->columns = $columns; $this->date = $date; $this->divider = $divider; $this->html = $html; $this->image = $image; $this->radio = $radio; $this->segment = $segment; $this->select = $select; $this->submit = $submit; $this->text = $text; $this->textarea = $textarea; $this->heading = $heading; $this->paragraph = $paragraph; } public function renderBlock(array $block, array $formSettings, ?int $formId): string { $html = ''; if ($formId) { $formSettings['id'] = $formId; } // This is used to properly show validation message when // the same form is rendered on a page multiple times $block['validation_id'] = Security::generateRandomString(); switch ($block['type']) { case FormEntity::HTML_BLOCK_TYPE: $html .= $this->html->render($block, $formSettings); break; case FormEntity::HEADING_BLOCK_TYPE: $html .= $this->heading->render($block); break; case FormEntity::IMAGE_BLOCK_TYPE: $html .= $this->image->render($block); break; case FormEntity::PARAGRAPH_BLOCK_TYPE: $html .= $this->paragraph->render($block); break; case FormEntity::DIVIDER_BLOCK_TYPE: $html .= $this->divider->render($block); break; case FormEntity::CHECKBOX_BLOCK_TYPE: $html .= $this->checkbox->render($block, $formSettings, $formId); break; case FormEntity::RADIO_BLOCK_TYPE: $html .= $this->radio->render($block, $formSettings, $formId); break; case FormEntity::SEGMENT_SELECTION_BLOCK_TYPE: $html .= $this->segment->render($block, $formSettings, $formId); break; case FormEntity::DATE_BLOCK_TYPE: $html .= $this->date->render($block, $formSettings, $formId); break; case FormEntity::SELECT_BLOCK_TYPE: $html .= $this->select->render($block, $formSettings, $formId); break; case FormEntity::TEXT_BLOCK_TYPE: $html .= $this->text->render($block, $formSettings, $formId); break; case FormEntity::TEXTAREA_BLOCK_TYPE: $html .= $this->textarea->render($block, $formSettings, $formId); break; case FormEntity::SUBMIT_BLOCK_TYPE: $html .= $this->submit->render($block, $formSettings); break; } return $html; } public function renderContainerBlock(array $block, string $content) { $html = ''; switch ($block['type']) { case FormEntity::COLUMNS_BLOCK_TYPE: $html .= $this->columns->render($block, $content); break; case FormEntity::COLUMN_BLOCK_TYPE: $html .= $this->column->render($block, $content); break; } return $html; } }