Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
There is a lot of code in helper functions to build token trees which makes more sense in a service. Let's move it to a service.
Proposed resolution
Add a service.
Remaining tasks
User interface changes
None
API changes
The functions may still remain or can be removed depending on what is required.
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#5 | move_token_builder-2641076-5.patch | 12.36 KB | hussainweb |
| |||
#5 | interdiff-2-5.txt | 5.35 KB | hussainweb |
Comments
Comment #2
hussainwebHere is the patch for testing. The changes relevant to the issue are in the .txt file which needs to be reviewed. It has to be applied over the patch in #2640612-11: Move token information functions to a service as it makes use of the token service. I have attached a combined patch so that the tests work.
Comment #3
hussainwebComment #4
BerdirLooks like a good start. Some specific feedback below.
AFAIK, we currently have 0 test coverage for the token tree. Would be great to start adding some UI tests there, could be a pretty simple start, e.g. asserting that a bunch of tokens and nested tokens show up on the page. Then we can extend it with regression tests if we ever have to fix tests or add new features there. Want to open a follow-up for that?
Please inject the services that we actually need.
weird drupal_static() leftover.
should be $this->flattenTree()
pretty sure those functions are just internal helper functions for the theme functions, I don't think we need to keep them around.
Comment #5
hussainwebAddressing comments in #4. I am still manually testing this but putting this up for review.
Comment #6
hussainwebOkay, I tested this manually across various pages (including other contrib modules). It works great on all pages.
Comment #7
hussainwebFiled #2641136: Write tests for token tree builder for automated tests.
Comment #9
BerdirCommitted. Nice, one step closer to unit testable code.
I think you're already working on converting the remaining tree theme code there to twig where you will probably convert these calls. But lets also do a follow-up to convert all other calls to this function, including properly injecting the service into controllers and so on.
Comment #10
hussainwebCreated #2641386: Remove @deprecated token tree builder functions.