Feature: #83608 - PSR-14 event to modify resolved default upload folder¶
See forge#83608
Description¶
A new PSR-14 event \TYPO3\
has been added, which allows the default upload folder to be modified after it has
been resolved for the current page or user.
The new event can be used as a better alternative to the
$GLOBALS
hook, serving the same purpose.
The event features the following methods:
get
returns the currently resolvedUpload Folder () $upload
Folder set
sets a new upload folderUpload Folder () get
returns the PID of the record we fetch the upload folder forPid () get
returns the table name of the record we fetch the upload folder forTable () get
returns the field name of the record we fetch the upload folder forField Name ()
Registration of the event in your extension's Services.
:
MyVendor\MyExtension\Resource\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/after-default-upload-folder-was-resolved-event-listener'
The corresponding event listener class:
namespace MyVendor\MyExtension\Resource\EventListener;
use TYPO3\CMS\Core\Resource\Event\AfterDefaultUploadFolderWasResolvedEvent;
final class MyEventListener
{
public function __invoke(AfterDefaultUploadFolderWasResolvedEvent $event): void
{
$event->setUploadFolder($event->getUploadFolder()->getStorage()->getFolder('/'));
}
}
Impact¶
As resolving the event was moved from Backend
to its own
Default
class, this event is now the preferred way
of modifying the default upload folder.