public static function WebformAttachmentUrl::getFileName in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_attachment/src/Element/WebformAttachmentUrl.php \Drupal\webform_attachment\Element\WebformAttachmentUrl::getFileName()
Get a webform attachment's file name.
Parameters
array $element: The webform attachment element.
\Drupal\webform\WebformSubmissionInterface $webform_submission: A webform submission.
Return value
mixed|string The attachment's file name.
Overrides WebformAttachmentBase::getFileName
File
- modules/
webform_attachment/ src/ Element/ WebformAttachmentUrl.php, line 51
Class
- WebformAttachmentUrl
- Provides a 'webform_attachment_url' element.
Namespace
Drupal\webform_attachment\ElementCode
public static function getFileName(array $element, WebformSubmissionInterface $webform_submission) {
if (!isset($element['#filename']) && !empty($element['#url'])) {
/** @var \Drupal\webform\WebformTokenManagerInterface $token_manager */
$token_manager = \Drupal::service('webform.token_manager');
$url = $token_manager
->replace($element['#url'], $webform_submission);
return basename($url);
}
else {
return parent::getFileName($element, $webform_submission);
}
}