Feature: #102624 - PSR-14 event for modifying image source collection
See forge#102624
Description
A new PSR-14 event \TYPO3\
has been introduced which serves as a drop-in replacement for the now removed
hook $GLOBALS
.
The event is being dispatched in Content
for each configured source
and allows to enrich the final
source collection result.
To modify get
result, the following methods are available:
set
: Allows to modify a source collection based on the corresponding configurationSource Collection () get
: Returns the source collectionSource Collection () get
: Returns the current full source collection, being enhanced by the currentFull Source Collection () source
Collection get
: Returns the currentSource Configuration () source
configurationCollection get
: Returns the corresponding renderer configuration for the source collectionSource Render Configuration () get
: Returns the currentContent Object Renderer () Content
instanceObject Renderer
Example
The event listener class, using the PHP attribute #
for
registration:
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Frontend\ContentObject\Event\ModifyImageSourceCollectionEvent;
final class ModifyImageSourceCollectionEventListener
{
#[AsEventListener]
public function __invoke(ModifyImageSourceCollectionEvent $event): void
{
$event->setSourceCollection('<source src="bar-file.jpg" media="(max-device-width: 600px)">');
}
}
Impact
Using the new PSR-14 event, it's now possible to manipulate the
source
's, used for an Image
.