Feature #59497
closed
Added by Bernhard Kraft about 10 years ago.
Updated over 4 years ago.
Sprint Focus:
Needs Decision
Description
At some time the TYPO3 project introduced interfaces for hooks. This seemed as a good idea so a developer does have a template when creating a hook class. Since the signal/slot concept was introduced the concept of interfaces was somehow put in the background.
Proposal: Have to kinds of slot/signals. We could denote the first current one "flexible slots" and the new one "typed slots". Such a new typed slot would need to implement some specific interface as required by the dispatch call. Altough this takes away the possibility to connect a signal to "any" method it rather mimics the old hooks. At least those having an interface.
The title should read "Typed slots"
- Subject changed from Types Slots to Typed Slots
Please correct me if I'm wrong, but you are trying to mix two design patterns. Hooks belong to the template method pattern and SignalSlots are a observer pattern.
The discussion wich one is better is another one, but mixing those two sounds incredible wrong to me.
Well. Then it sounds this for you.
For me both are variants of the same principle. Don't paint hooks black because they are called hooks.
From wikipedia "Observer pattern" my comments in ((double brackets)):
The observer pattern is a software design pattern in which an object ((i.e. TYPO3\CMS\Core\Database\DatabaseConnection)), called the subject, maintains a list of its dependents ((i.e. DatabaseConnection::$preProcessHookObjects)), called observers, and notifies them automatically of any state changes, usually by calling one of their methods ((i.e. @line 477: $hookObject->INSERTquery_preProcessAction() )).
Altough the description isn't completly exact: The list is not maintained by the subject but rather from outside. But this is also true for our current signal/slot approach: The connection list isn't maintained by the observing object (the subject) but rather by a class instance it holds.
So neither of both implementations is exactly what wikipedia (Or Fab4) describe as observer pattern.
- Status changed from New to Closed
Hey,
for v10, we're going with PSR-14, which is fully typed solution, so this feature for signal slot won't make it, but PSR-14 this is already built-in the logic. Thanks for the report, it's so good to see that your ideas have made it all the way to a PHP PSR standard.
All the best,
Benni.
- Sprint Focus changed from PRC to Needs Decision
Also available in: Atom
PDF