You are here

public function WebformSubmissionViewBuilder::buildElements in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/WebformSubmissionViewBuilder.php \Drupal\webform\WebformSubmissionViewBuilder::buildElements()

Build element display items from elements and submitted data.

Parameters

array $elements: Webform elements.

\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.

array $options:

  • excluded_elements: An array of elements to be excluded.
  • ignore_access: Flag to ignore private and/or access controls and always display the element.
  • email: Format element to be send via email.

string $format: Output format set to html or text.

Return value

array A render array displaying the submitted values.

Overrides WebformSubmissionViewBuilderInterface::buildElements

1 call to WebformSubmissionViewBuilder::buildElements()
WebformSubmissionViewBuilder::buildComponents in src/WebformSubmissionViewBuilder.php
Builds the component fields and properties of a set of entities.

File

src/WebformSubmissionViewBuilder.php, line 181

Class

WebformSubmissionViewBuilder
Render controller for webform submissions.

Namespace

Drupal\webform

Code

public function buildElements(array $elements, WebformSubmissionInterface $webform_submission, array $options = [], $format = 'html') {
  $build_method = 'build' . ucfirst($format);
  $build = [];
  foreach ($elements as $key => $element) {
    if (!WebformElementHelper::isElement($element, $key)) {
      continue;
    }

    /** @var \Drupal\webform\Plugin\WebformElementInterface $webform_element */
    $webform_element = $this->elementManager
      ->getElementInstance($element);

    // Replace tokens before building the element.
    $webform_element
      ->replaceTokens($element, $webform_submission);
    if ($build_element = $webform_element
      ->{$build_method}($element, $webform_submission, $options)) {
      $build[$key] = $build_element;
      if (!$this
        ->isElementVisible($element, $webform_submission, $options)) {
        $build[$key]['#access'] = FALSE;
      }
    }
  }
  return $build;
}