Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
ModifyFileDumpEvent
New in version 11.4
The Modify
is fired in the File
and allows extensions
to perform additional access / security checks before dumping a file. The
event does not only contain the file to dump but also the PSR-7 Request.
In case the file dump should be rejected, the event has to set a PSR-7
response, usually with a 403
status code. This will then immediately
stop the propagation.
With the event, it's not only possible to reject the file dump request, but also to replace the file, which should be dumped.
Example
Registration of the event in the Services.
:
MyVendor\MyPackage\Resource\MyEventListener:
tags:
- name: event.listener
identifier: 'my-package/resource/my-event-listener'
The corresponding event listener class:
use TYPO3\CMS\Core\Resource\Event\ModifyFileDumpEvent;
final class MyEventListener {
public function __invoke(ModifyFileDumpEvent $event): void
{
// do magic here
}
}
API
- class ModifyFileDumpEvent
-
- Fully qualified name
-
\TYPO3\
CMS\ Core\ Resource\ Event\ Modify File Dump Event
Event that is triggered when a file should be dumped to the browser, allowing to perform custom security/access checks when accessing a file through a direct link, and returning an alternative Response.
It is also possible to replace the file during this event, but not setting a response.
As soon as a custom Response is added, the propagation is stopped.
- setFile ( TYPO3\\CMS\\Core\\Resource\\ResourceInterface $file)
-
- param TYPO3\\CMS\\Core\\Resource\\ResourceInterface $file
-
the file