You are here

protected function WebformCompositeBase::getManagedFileIdsFromData in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformCompositeBase.php \Drupal\webform\Plugin\WebformElement\WebformCompositeBase::getManagedFileIdsFromData()

Get composite element's file ids from data array.

Parameters

array $element: A composite element.

array $data: A submission data array.

string $composite_key: The composite sub-element key.

Return value

array An array of file ids.

2 calls to WebformCompositeBase::getManagedFileIdsFromData()
WebformCompositeBase::getEmailAttachments in src/Plugin/WebformElement/WebformCompositeBase.php
Get files as email attachments.
WebformCompositeBase::postSave in src/Plugin/WebformElement/WebformCompositeBase.php
Acts on a saved webform submission element before the insert or update hook is invoked.

File

src/Plugin/WebformElement/WebformCompositeBase.php, line 1410

Class

WebformCompositeBase
Provides a base for composite elements.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function getManagedFileIdsFromData(array $element, array $data, $composite_key) {
  $element_key = $element['#webform_key'];
  if (empty($data[$element_key])) {
    return [];
  }
  $fids = [];
  $items = $this
    ->hasMultipleValues($element) ? $data[$element_key] : [
    $data[$element_key],
  ];
  foreach ($items as $item) {
    if (!empty($item[$composite_key])) {
      $fids[] = $item[$composite_key];
    }
  }
  return $fids;
}