[TYPO3-core] SignalSlot returns (was: Broken: TYPO3/TYPO3.CMS#3323 (master - 7f2cd46))
Helmut Hummel
helmut.hummel at typo3.org
Mon Jun 23 14:27:51 CEST 2014
Hi!
On 22.06.14 19:01, Travis CI wrote:
> View the changeset: https://github.com/TYPO3/TYPO3.CMS/compare/bde6364c17fa...7f2cd468e1e0
>
> View the full build log and details: https://travis-ci.org/TYPO3/TYPO3.CMS/builds/28166942
The problem with that is the following:
The API to emit a signal is the following:
$signalClassName = 'string';
$signalName = 'string';
$signalArguments = array($val1, $val2);
$signalSlotDispatcher->dispatch($signalClassName, $signalName,
$signalArguments)
Registered slots would then have a method/function like this:
function mySlot($val1, $val2) {}
Although violating a bit the signal/slot pattern, we introduced the
possibility that signals return the (potentially modified) arguments.
function mySlot($val1, $val2) {
return array($val1, $val2);
}
Somehow signals were introduced in the core which used the following
code to emit a signal:
$signalSlotDispatcher->dispatch(__CLASS__, 'signalName', array('key' =>
'value');
And all slots using such signals would have to "know" the keys by
convention and return an array accordingly:
function mySlot($val1) {
return array('key' => $val);
}
To me, using keys for an array of arguments does not make sense there is
no way to ensure correctness of the keys, so I decided with Nicole to
just clean these places up and use plain indexed arrays everywhere.
This change got merged now but unfortunately this broke some places
where the slots still returned array keys but the surrounding code was
changed.
Two questions:
1. It turns out such a change is not backwards compatible. Do we still
want to change it?
2. How do we want the "extended" signal slot pattern to behave in the
future and how should the calling code look like? I would suggest:
function mySlot($val1, $val2) {
return array($val1, $val2);
}
list($val1, $val2) = $signalSlotDispatcher->dispatch(__CLASS__,
'signalName', array($val1, $val2);
Kind regards,
Helmut
--
Helmut Hummel
Release Manager TYPO3 6.0
TYPO3 Core Developer, TYPO3 Security Team Member
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the TYPO3-team-core
mailing list