73632[POC][FEATURE] Introduce TCA field transformers
Commit message
Review
-
Code review CR 0
-
Verified V 0
Files 17
- typo3/sysext/backend/Classes/Form/Element/AbstractFormElement.php+5 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/Alnum.phpnew+46 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/Casing.phpnew+41 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/DomainName.phpnew+35 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/Filesize.phpnew+44 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/HashedPassword.phpnew+50 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/Integer.phpnew+31 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/JavaScriptModuleInterface.php1new+23 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/Md5.phpnew+34 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/NoSpace.phpnew+31 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/NumberBase.phpnew+47 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/TransformerInterface.phpnew+23 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/Trim.phpnew+31 −0
- typo3/sysext/core/Classes/DataHandling/DataTransformers/Year.phpnew+35 −0
- typo3/sysext/core/Classes/DataHandling/DataHandler.php+24 −3
- typo3/sysext/core/Configuration/TCA/be_users.php+29 −4
- typo3/sysext/core/Configuration/TCA/pages.php+62 −12
Review log 911
-
Andreas Kienast uploaded patch set 1 02/21/22, 17:38
-
Martin Kutschker commented on patch set 1 02/21/22, 17:51
Configuration of modifiers is very good. I don't like to write a padding modifier for all lenght and character combinations. "Modifier" may not be the best name for it. IMHO it lacks the information of the direction which is "input". And I like "transformation" better: so I'd go for "InputTransformationInterface". Why would the JS module be required? Will the transformation happen a the client AND the server side? How will double transformation be prevented?ModifierInterface.php:22The return value seems quite restriced. What about floats? Can booleans and Date objects be handled at this point? -
core-ci voted on patch set 1 V -1 02/21/22, 17:53 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24001
-
Andreas Kienast commented on patch set 1 02/21/22, 18:05
Reply
Currently, FormEngine applies transformations as well so a backend user will see an immediate effect, which is then submitted to DataHandler in the end. It's true this will cause a double transformation, but this wasn't an issue in the past, as a second transformation of the same type shouldn't alter the value again.ModifierInterface.php:22Reply UnresolvedThat's true, I just took what I've noticed by a quick look. The current "eval" system cannot handle bools and DateType types, but I don't see a reason right now to not allow it in the future. -
Martin Kutschker commented on patch set 1 02/21/22, 19:10
Reply
Not if it's to be type safe. In the examples of the first commit we have an integer modifier that accepts a string and returns an int. But of course we can cast all values again to strings. Perhaps the data flow is currently wrong. What if the modifier would return a value object instead of a scalar? Then the DataHandler could accept either a string to modify or an aleady modified value. -
Andreas Kienast commented on patch set 1 02/21/22, 19:28
Reply
I get your point. I've made the types less strict in my code right now, Symfony does the same with their Data Transformers (https://symfony.com/doc/current/form/data_transformers.html). Talking about what Symfony does: sometimes a "transform back" doesn't make much sense, e.g. for trimming or password hashing, hence I'd make such transformation optional via an interface (FromPersistenceTransformerInterface or alike). -
Andreas Kienast uploaded patch set 2 02/21/22, 21:15
-
Martin Kutschker commented on patch set 1 02/21/22, 21:21
Reply Unresolved
I know. I assume it depends on the purpose of the transformation. Is it directly from external representation to storage presentation, ie human readable strings to database types? Or is it a two-step process: human readable to PHP type, PHP type to database type. Which reminds me to question to usefulness of the transformations of "eval" that do type juggling: "int" and "double2". Both are already defined by the database type. -
core-ci voted on patch set 2 V -1 02/21/22, 21:23 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/24014
-
Benni Mack commented on patch set 2 02/22/22, 09:15
JavaScriptModuleInterface.php:20Unresolvedmaybe this should rather be a "ClientTransformationInterface"? -
Benni Mack abandoned the change 05/03/23, 09:21
not in use right now