public static function WebformAttachmentBase::processWebformAttachment in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_attachment/src/Element/WebformAttachmentBase.php \Drupal\webform_attachment\Element\WebformAttachmentBase::processWebformAttachment()
Processes a 'webform_attachment' element.
File
- modules/
webform_attachment/ src/ Element/ WebformAttachmentBase.php, line 38
Class
- WebformAttachmentBase
- Provides a base class for 'webform_attachment' elements.
Namespace
Drupal\webform_attachment\ElementCode
public static function processWebformAttachment(&$element, FormStateInterface $form_state, &$complete_form) {
$form_object = $form_state
->getFormObject();
// Attachments only work for webform submissions.
if (!$form_object instanceof WebformSubmissionForm) {
$element['#access'] = FALSE;
return $element;
}
/** @var \Drupal\webform\WebformSubmissionInterface $webform_submission */
$webform_submission = $form_object
->getEntity();
// Attachments only work for completed and saved webform submissions.
if (!$webform_submission
->id() || !$webform_submission
->isCompleted()) {
$element['#access'] = FALSE;
return $element;
}
// Link to file download.
$element['link'] = static::getFileLink($element, $webform_submission);
return $element;
}