WebformSubmissionCompositeField.php in Webform Views Integration 8.5
File
src/Plugin/views/field/WebformSubmissionCompositeField.php
View source
<?php
namespace Drupal\webform_views\Plugin\views\field;
use Drupal\views\ResultRow;
class WebformSubmissionCompositeField extends WebformSubmissionField {
public function render(ResultRow $values) {
$webform_submission = $this
->getEntity($values);
if ($webform_submission && $webform_submission
->access('view')) {
$webform = $webform_submission
->getWebform();
$format = $this->options['webform_element_format'];
$element_key = $this->definition['webform_submission_field'];
$composite_key = $this->definition['webform_submission_property'];
$element = $webform
->getElement($element_key, TRUE);
if (!$element) {
return [];
}
$element['#format'] = $format;
$composite_element = $element['#webform_composite_elements'][$composite_key];
$composite_element['#webform_key'] = $element['#webform_key'];
$options = [
'composite_key' => $composite_key,
];
if (!$this->webformElementManager
->getElementInstance($element)
->hasMultipleValues($element) || !$this->options['webform_multiple_value']) {
if (!$this->options['webform_multiple_value']) {
$options['delta'] = $this->options['webform_multiple_delta'];
}
return $this->webformElementManager
->invokeMethod('formatHtml', $composite_element, $webform_submission, $options);
}
$build = [
'#theme' => 'item_list',
'#items' => [],
];
$i = 0;
do {
$options['delta'] = $i;
$formatted_item = $this->webformElementManager
->invokeMethod('formatHtml', $composite_element, $webform_submission, $options);
$build['#items'][] = $formatted_item;
$i++;
} while ($formatted_item);
array_pop($build['#items']);
return $build;
}
return [];
}
}