public function WebformDefaultExceptionHtmlSubscriber::on403RedirectPrivateFileAccess in Webform 6.x
Same name and namespace in other branches
- 8.5 src/EventSubscriber/WebformDefaultExceptionHtmlSubscriber.php \Drupal\webform\EventSubscriber\WebformDefaultExceptionHtmlSubscriber::on403RedirectPrivateFileAccess()
Redirect to user login when access is denied to private webform file.
Parameters
\Symfony\Component\HttpKernel\Event\ExceptionEvent $event: The event to process.
See also
\Drupal\webform\Plugin\WebformElement\WebformManagedFileBase::accessFileDownload
1 call to WebformDefaultExceptionHtmlSubscriber::on403RedirectPrivateFileAccess()
- WebformDefaultExceptionHtmlSubscriber::on403 in src/
EventSubscriber/ WebformDefaultExceptionHtmlSubscriber.php - Handles a 403 error for HTML.
File
- src/
EventSubscriber/ WebformDefaultExceptionHtmlSubscriber.php, line 135
Class
- WebformDefaultExceptionHtmlSubscriber
- Event subscriber to redirect to login form when webform settings instruct to.
Namespace
Drupal\webform\EventSubscriberCode
public function on403RedirectPrivateFileAccess(ExceptionEvent $event) {
$path = $event
->getRequest()
->getPathInfo();
// Make sure the user is trying to access a private webform file upload.
if (strpos($path, '/system/files/webform/') !== 0) {
return;
}
// Make private webform file upload is not a temporary file.
// @see \Drupal\webform\Plugin\WebformElement\WebformManagedFileBase::postSave
if (strpos($path, '/_sid_/') !== FALSE) {
return;
}
// Check that private file redirection is enabled.
if (!$this->configFactory
->get('webform.settings')
->get('file.file_private_redirect')) {
return;
}
$message = $this->configFactory
->get('webform.settings')
->get('file.file_private_redirect_message');
$this
->redirectToLogin($event, $message);
}