public function WebformMarkupBase::buildText in Webform 6.x
Same name and namespace in other branches
- 8.5 src/Plugin/WebformElement/WebformMarkupBase.php \Drupal\webform\Plugin\WebformElement\WebformMarkupBase::buildText()
Build an element as text element.
Parameters
array $element: An element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
array $options: An array of options.
Return value
array A render array representing an element as text.
Overrides WebformDisplayOnTrait::buildText
2 calls to WebformMarkupBase::buildText()
- ProcessedText::buildText in src/
Plugin/ WebformElement/ ProcessedText.php - Build an element as text element.
- WebformMarkup::buildText in src/
Plugin/ WebformElement/ WebformMarkup.php - Build an element as text element.
2 methods override WebformMarkupBase::buildText()
- ProcessedText::buildText in src/
Plugin/ WebformElement/ ProcessedText.php - Build an element as text element.
- WebformMarkup::buildText in src/
Plugin/ WebformElement/ WebformMarkup.php - Build an element as text element.
File
- src/
Plugin/ WebformElement/ WebformMarkupBase.php, line 100
Class
- WebformMarkupBase
- Provides a base 'markup' element.
Namespace
Drupal\webform\Plugin\WebformElementCode
public function buildText(array $element, WebformSubmissionInterface $webform_submission, array $options = []) {
// Hide element if it should not be displayed on 'view'.
if (!$this
->isDisplayOn($element, WebformElementDisplayOnInterface::DISPLAY_ON_VIEW)) {
return [];
}
if ($this
->isContainer($element)) {
// Must remove #prefix and #suffix.
unset($element['#prefix'], $element['#suffix']);
/** @var \Drupal\webform\WebformSubmissionViewBuilderInterface $view_builder */
$view_builder = $this->entityTypeManager
->getViewBuilder('webform_submission');
$value = $view_builder
->buildElements($element, $webform_submission, $options, 'text');
// Since we are not passing this element to the
// webform_container_base_text template we need to replace the default
// sub elements with the value (i.e. renderable sub elements).
if (is_array($value)) {
$element = $value + $element;
}
}
return $element;
}