Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
Various helper functions and info functions, especially token_get_info() should converted to a service, either by replacing the core Token service, or adding a new service that wraps the one from core, or a mix of both. That would allow to write clean tests for a lot of complex code there, and remove the need for all those drupal_static()'s, which makes the code ugly right now.
Comments
Comment #1
XanoI second this. All code, except for route controllers, seems to be procedural still. For Token to become useful and of high quality in Drupal 8, the code base must be converted to interfaces and classes. Only then can the Token code base be unit-tested and can other developers inject Token's code into their own, while still being able to unit test it. It will also make maintenance on Token itself much easier, as changes can be made much more easily without breaking BC.
Marking this major because of the aforementioned reasons.
Comment #2
Dave ReidThe code should already be tested, just not unit tested. The code as is has worked pretty well in its lifetime for Drupal 7 without major issues that you've raised. As such would ask for the priority to be respected.
Comment #3
kim.pepperHi Dave,
Are the maintainers happy with the approach? It would be good to know, before any effort gets put into this issue.
Kim
Comment #4
Dave ReidMy position hasn't changed. I don't think this is a priority over other things.
Comment #5
couturier CreditAttribution: couturier as a volunteer commentedIs this still something that will block an official Token release for D8? The last activity on this thread was 7 months ago, and an official D8 release is now here in November 2015. Can we move this to consideration for D9?
Comment #6
Dave ReidPlease do not go through marking issues as won't fix. They are still valid, and only maintainers should be marking issues as won't fix as it's ultimately their decision to make.
Comment #7
BerdirI think we've moved enough now to consider this closed. There are a bunch of load helper functions left but they're only called from hook tokens implementations and are not worth converting IMHO.
And some of the remaining render/theme (cache) functions will be dealt with in #2430823: Token tree rendering uses a lot of theme functions and can not be render cached.