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.

Proposed resolution

Remaining tasks

User interface changes

API changes


Xano’s picture

Priority: Normal » Major

I 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.

Dave Reid’s picture

Priority: Major » Normal

The 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.

kim.pepper’s picture

Hi Dave,

Are the maintainers happy with the approach? It would be good to know, before any effort gets put into this issue.


Dave Reid’s picture

Priority: Normal » Minor

My position hasn't changed. I don't think this is a priority over other things.

couturier’s picture

Category: Task » Feature request
Status: Active » Closed (won't fix)

Is 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?

Dave Reid’s picture

Status: Closed (won't fix) » Active

Please 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.

Berdir’s picture

Category: Feature request » Plan
Status: Active » Fixed

I 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.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.