Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TYPO3 12: Hook - Implementation of interface EventExecutionHookInterface not validated, switch to PSR-14 events #42

Open
3l73 opened this issue Oct 2, 2024 · 0 comments

Comments

@3l73
Copy link

3l73 commented Oct 2, 2024

The controller EventController uses the hook postEventExecution defined in $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fourallportal']['postEventExecution'].

It expects the object to be an instance of interface \Crossmedia\Fourallportal\Hook\EventExecutionHookInterface but never validate if the object indeed implements that interface.

if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fourallportal']['postEventExecution'] ?? null)) {

Instead of using a hook, the implementation should be migrated to events and the event dispatcher.

https://docs.typo3.org/m/typo3/reference-coreapi/12.4/en-us/ApiOverview/Events/EventDispatcher/Index.html

The use of events allows a better type binding and it does not need to be checked if the hook implements the correct interface.

Currently the hooks are only executed if a backend user clicks a button within the backend. Moving the execution of the events from the controller into class EventExecutionService, the events will be triggered even in CLI oder scheduler context.

Following two events could be implemented:

  • \Crossmedia\Fourallportal\Event\AfterProcessMultipleEvents
  • \Crossmedia\Fourallportal\Event\AfterProcessSingleEvent

The event \Crossmedia\Fourallportal\Event\AfterProcessMultipleEvents should be triggered at the end ob method processEvents()

The event \Crossmedia\Fourallportal\Event\AfterProcessSingleEvent should be triggered at the end ob method processEvent()

$parameters?->countExecutedEvent();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant