public static function WebformAttachmentBase::getFileUrl 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::getFileUrl()
Get a webform attachment's download URL.
Parameters
array $element: The webform attachment element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
Return value
\Drupal\Core\Url|null A webform attachment's download URL. Return NULL if the submission is not saved to the database.
Overrides WebformAttachmentInterface::getFileUrl
1 call to WebformAttachmentBase::getFileUrl()
- WebformAttachmentBase::getFileLink in modules/
webform_attachment/ src/ Element/ WebformAttachmentBase.php - Get a webform attachment's file link.
File
- modules/
webform_attachment/ src/ Element/ WebformAttachmentBase.php, line 123
Class
- WebformAttachmentBase
- Provides a base class for 'webform_attachment' elements.
Namespace
Drupal\webform_attachment\ElementCode
public static function getFileUrl(array $element, WebformSubmissionInterface $webform_submission) {
if (!$webform_submission
->id()) {
return NULL;
}
$route_name = 'entity.webform.user.submission.attachment';
$route_parameters = [
'webform' => $webform_submission
->getWebform()
->id(),
'webform_submission' => $webform_submission
->id(),
'element' => $element['#webform_key'],
'filename' => static::getFileName($element, $webform_submission),
];
$route_options = [
'absolute' => TRUE,
];
$url = Url::fromRoute($route_name, $route_parameters, $route_options);
return $url;
}