stable

Clone or download

Read-only

chore: Hooks can be listened to with Attributes

As of today, for plugins, listening to hooks is tedious, there is a lot of copy/paste and things are scattered at different places: * Usage of hooks must be declared in `getHooksAndCallbacks` * It's not easy to find the hook that correspond to a callback * There is a lot of repetition of the event: at hook declaration (`getHooksAndCallbacks`), at the name of the callback, at the first parameter name. Using attributes, greatly simplify that: * Declaration of hook listening callback is done at callback level (no more back & forth with top of the class) * Callback can be named diffrently from hook (psr1 compat, typo in hook name, more precise naming) * No need to repeat the Event name, the paramter of the hook is enough. In addition to that, this patch also brings the possibility to have `NAME` less events. That further reduce the boilerplate of Event declaration and make them PSR-14 compatible. Part of: request #31113 Simplify hook listening for plugins Change-Id: Ie85be50e430b1ca889b413f2d6ba601b5c4dbc10

Modified Files

Name
A adr/0021-attributes-based-events.md +41 −0 Go to diff View file
M adr/index.md +1 −0 Go to diff View file
M plugins/svn/include/svnPlugin.php +15 −20 Go to diff View file
M src/common/Event/Dispatchable.php +1 −0 Go to diff View file
M src/common/Event/EventManager.class.php +2 −1 Go to diff View file
M src/common/Layout/HomePage/LastMonthStatisticsCollectorSVN.php +0 −1 Go to diff View file
A src/common/Plugin/ListeningToEvent.php +28 −0 Go to diff View file
A src/common/Plugin/ListeningToEventClass.php +29 −0 Go to diff View file
A src/common/Plugin/ListeningToEventName.php +32 −0 Go to diff View file
M src/common/Plugin/Plugin.php +60 −1 Go to diff View file
M tests/unit/common/Plugin/PluginTest.php +65 −1 Go to diff View file
M tests/unit/common/event/EventManagerTest.php +16 −1 Go to diff View file