Closed aschempp closed 5 years ago
The code for "hook with return validation" is more complex than the original code, so I'm not sure about this.
The code for "hook with return validation" is more complex than the original code
Why is it more complex? The whole point is to get rid of the loop and System::importStatic
in every implementation… This would also very much simplify things like a third option instead of array and callbacks (like triggering an event or whatever stupid thing we come up with 😁 )
... and it would allow making changes/optimizing at a central place. Right now the code segments have no common semantic.
@leofeyer @Toflar @ausi would anyone agree this is a nice feature, or should we close the PR?
I don't see the use case, sorry. It's only for hooks and we don't want to extend any logic for hooks imho.
I also vote to close the PR, because
The code for "hook with return validation" is more complex than the original code
Just a quick idea I came up with to deal with the repetitive code when calling hooks and callbacks.
Example usage:
Call simple hook (https://github.com/contao/core-bundle/blob/fa05410fbd75cca7655599e59972475fe371ca0e/src/Resources/contao/pages/PageRegular.php#L77-L85)
Call hook with return value (https://github.com/contao/core-bundle/blob/60403e47690ffcc253096750719a7d310f5f4561/src/Resources/contao/classes/FrontendTemplate.php#L56-L64)
Call hook with return validation (https://github.com/contao/core-bundle/blob/5a411a7383e7ef24289bc6a739269ae572a52db1/src/Resources/contao/library/Contao/InsertTags.php#L985-L999)
The same works for every DCA callback. We could also add a quick helper to call
isset
andis_array
on hooks, but that won't work for callbacks.