-
Notifications
You must be signed in to change notification settings - Fork 638
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[!!!][FEATURE] Add PSR-14 Events for modifying cObj stdWrap
This replaces the previously available hook $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'] which is therefore now removed. Instead of one hook class, containing different methods, required by the deprecated `ContentObjectStdWrapHookInterface` does this patch add four dedicated PSR-14 Events, which can be used individually. Additionally, using the parent `EnhanceStdWrapEvent` it's still possible to register listeners, which are called on each occurrence. Resolves: #102745 Releases: main Change-Id: I3f85dca7673b8af23a3ed0c896d1cb48af4bfb4b Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/82305 Reviewed-by: Benni Mack <benni@typo3.org> Tested-by: Stefan Bürk <stefan@buerk.tech> Reviewed-by: Oliver Bartsch <bo@cedev.de> Reviewed-by: Simon Schaufelberger <simonschaufi+typo3@gmail.com> Reviewed-by: Stefan Bürk <stefan@buerk.tech> Tested-by: Benni Mack <benni@typo3.org> Tested-by: Oliver Bartsch <bo@cedev.de> Tested-by: core-ci <typo3@b13.com>
- Loading branch information
Showing
18 changed files
with
496 additions
and
198 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...ocumentation/Changelog/13.0/Breaking-102745-RemovedContentObjectStdWrapHook.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.. include:: /Includes.rst.txt | ||
|
||
.. _breaking-102745-1705054472: | ||
|
||
====================================================== | ||
Breaking: #102745 - Removed ContentObject stdWrap hook | ||
====================================================== | ||
|
||
See :issue:`102745` | ||
|
||
Description | ||
=========== | ||
|
||
The ContentObject stdWrap hook :php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap']` | ||
has been removed in favor of the more powerful PSR-14 Events: | ||
|
||
* :php:`\TYPO3\CMS\Frontend\ContentObject\Event\BeforeStdWrapFunctionsInitializedEvent` | ||
* :php:`\TYPO3\CMS\Frontend\ContentObject\Event\AfterStdWrapFunctionsInitializedEvent` | ||
* :php:`\TYPO3\CMS\Frontend\ContentObject\Event\BeforeStdWrapFunctionsExecutedEvent` | ||
* :php:`\TYPO3\CMS\Frontend\ContentObject\Event\AfterStdWrapFunctionsExecutedEvent` | ||
|
||
Impact | ||
====== | ||
|
||
Any hook implementation registered is not executed anymore | ||
in TYPO3 v13.0+. The extension scanner will report usages. | ||
|
||
|
||
Affected installations | ||
====================== | ||
|
||
TYPO3 installations with custom extensions using the hook. | ||
|
||
|
||
Migration | ||
========= | ||
|
||
The hook is removed without deprecation in order to allow extensions | ||
to work with TYPO3 v12 (using the hook) and v13+ (using the new Events) | ||
when implementing the Events as well without any further deprecations. | ||
Use the :doc:`PSR-14 Events <../13.0/Feature-102745-PSR-14EventsForModifyingContentObjectStdWrapFunctionality>` | ||
to allow greater influence in the functionality. | ||
|
||
.. index:: Frontend, PHP-API, FullyScanned, ext:frontend |
40 changes: 40 additions & 0 deletions
40
...cumentation/Changelog/13.0/Deprecation-102745-UnusedInterfaceForStdWrapHook.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.. include:: /Includes.rst.txt | ||
|
||
.. _deprecation-102745-1705054271: | ||
|
||
======================================================== | ||
Deprecation: #102745 - Unused interface for stdWrap hook | ||
======================================================== | ||
|
||
See :issue:`102745` | ||
|
||
|
||
Description | ||
=========== | ||
|
||
The ContentObject stdWrap hook required hook implementations to implement the | ||
:php:`\TYPO3\CMS\Frontend\ContentObject\ContentObjectStdWrapHookInterface`. | ||
Since the mentioned hook has been :doc:`removed <../13.0/Breaking-102745-RemovedContentObjectStdWrapHook>`, | ||
the interface is not in use anymore and has been marked as deprecated. | ||
|
||
Impact | ||
====== | ||
|
||
Using the interface has no effect anymore and the extension scanner will | ||
report any usage. | ||
|
||
Affected installations | ||
====================== | ||
|
||
TYPO3 installations using the PHP interface in custom extension code. | ||
|
||
Migration | ||
========= | ||
|
||
The PHP interface is still available for TYPO3 v13.x, so extensions can | ||
provide a version which is compatible with TYPO3 v12 (using the hook) | ||
and TYPO3 v13.x (using the new :doc:`PSR-14 Events <../13.0/Feature-102745-PSR-14EventsForModifyingContentObjectStdWrapFunctionality>`), | ||
at the same time. Remove any usage of the PHP interface and use the new PSR-14 | ||
Events to avoid any further problems in TYPO3 v14+. | ||
|
||
.. index:: Frontend, PHP-API, FullyScanned, ext:frontend |
86 changes: 86 additions & 0 deletions
86
....0/Feature-102745-PSR-14EventsForModifyingContentObjectStdWrapFunctionality.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
.. include:: /Includes.rst.txt | ||
|
||
.. _feature-102745-1705054628: | ||
|
||
================================================================================== | ||
Feature: #102745 - PSR-14 Events for modifying ContentObject stdWrap functionality | ||
================================================================================== | ||
|
||
See :issue:`102745` | ||
|
||
Description | ||
=========== | ||
|
||
Four new PSR-14 Events have been introduced: | ||
|
||
* :php:`\TYPO3\CMS\Frontend\ContentObject\Event\BeforeStdWrapFunctionsInitializedEvent` | ||
* :php:`\TYPO3\CMS\Frontend\ContentObject\Event\AfterStdWrapFunctionsInitializedEvent` | ||
* :php:`\TYPO3\CMS\Frontend\ContentObject\Event\BeforeStdWrapFunctionsExecutedEvent` | ||
* :php:`\TYPO3\CMS\Frontend\ContentObject\Event\AfterStdWrapFunctionsExecutedEvent` | ||
|
||
They serve as more powerful replacement of the :doc:`removed <../13.0/Breaking-102745-RemovedContentObjectStdWrapHook>`, | ||
:php:`$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap']` hook. | ||
|
||
Instead of registering one hook class, implementing four different methods - due | ||
to the :doc:`deprecated interface <../13.0/Deprecation-102745-UnusedInterfaceForStdWrapHook>` | ||
- extension authors are now able to register dedicated listeners. Next to the | ||
individual Events, it's also possible to register listeners to listen on the | ||
parent :php:`\TYPO3\CMS\Frontend\ContentObject\Event\EnhanceStdWrapEvent`. Since | ||
this event is extended by all other events, registered listeners are called | ||
on each occurrence. | ||
|
||
All Events provide the same functionality. The difference is only the execution | ||
order in which they are called in the stdWrap processing chain. | ||
|
||
Available methods: | ||
|
||
* :php:`getContent()` - Returns the current content (stdWrap result) | ||
* :php:`setContent()` - Allows to modify the final content (stdWrap result) | ||
* :php:`getConfiguration()` - Returns the corresponding TypoScript configuration | ||
* :php:`getContentObjectRenderer()` - Returns the current :php:`ContentObjectRenderer` instance | ||
|
||
Example | ||
======= | ||
|
||
The event listener class, using the PHP attribute :php:`#[AsEventListener]` for | ||
registration: | ||
|
||
.. code-block:: php | ||
use TYPO3\CMS\Core\Attribute\AsEventListener; | ||
use TYPO3\CMS\Frontend\ContentObject\Event\AfterStdWrapFunctionsExecutedEvent; | ||
use TYPO3\CMS\Frontend\ContentObject\Event\AfterStdWrapFunctionsInitializedEvent; | ||
use TYPO3\CMS\Frontend\ContentObject\Event\BeforeStdWrapFunctionsInitializedEvent; | ||
use TYPO3\CMS\Frontend\ContentObject\Event\EnhanceStdWrapEvent; | ||
final class EnhanceStdWrapEventListener | ||
{ | ||
#[AsEventListener] | ||
public function __invoke(EnhanceStdWrapEvent $event): void | ||
{ | ||
// listen to all events | ||
} | ||
#[AsEventListener] | ||
public function individualListener(BeforeStdWrapFunctionsInitializedEvent $event): void | ||
{ | ||
// listen on BeforeStdWrapFunctionsInitializedEvent only | ||
} | ||
#[AsEventListener] | ||
public function listenOnMultipleEvents(AfterStdWrapFunctionsInitializedEvent|AfterStdWrapFunctionsExecutedEvent $event): void | ||
{ | ||
// Union type to listen to different events | ||
} | ||
} | ||
Impact | ||
====== | ||
|
||
Using the new PSR-14 Events, it's now possible to fully influence the stdWrap | ||
functionality in TYPO3's Core API class :php:`\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer`. | ||
|
||
Using the new individual Events, developers are now also able to simplify their | ||
code by just listening for the relevant parts in the stdWrap processing. | ||
|
||
.. index:: Frontend, PHP-API, ext:frontend |
Oops, something went wrong.