Problem/Motivation

The theme_* functions are deprecated in Drupal 8 and will be removed. We are using theme_* functions for all our theme hooks. Let's move to twig. This issue deals with only converting token_tree_link which was prepared for this in previous issues. The other two theme hooks are tightly coupled with each other (see #2430823: Token tree rendering uses a lot of theme functions and can not be render cached) and can be refactored.

Proposed resolution

Convert token_tree_link to twig.

Remaining tasks

User interface changes

None

API changes

The function theme_token_tree_link is replaced by template_preprocess_token_tree_link.

Data model changes

None

Comments

hussainweb created an issue. See original summary.

hussainweb’s picture

Here is an initial patch. I am looking at ways to make the template file more usable. Currently, there is only one variable which just gets rendered. Any suggestions to improve?

Status: Needs review » Needs work

The last submitted patch, 2: use_twig_for_token_tree-2641336-2.patch, failed testing.

hussainweb’s picture

Status: Needs work » Needs review
StatusFileSize
new3.56 KB

I forgot to attach the template itself. I also added more variables and improved the twig file so that the link is constructed there, not in the preprocess function. This should allow for more flexibility if necessary.

berdir’s picture

Was wondering how this would end up looking exactly. I guess this is why I was wondering if we shouldn't use a #type. We could have a #type that extends from Link or so. But that would be another API change for everyone using it ;)

AFAIK link is a renderable that can be printed in the template with just {{ link }} ? I guess we can also do that. Still gives anyone an change to change this, but I actually think that almost nobody does that anyway..

hussainweb’s picture

Yes, I started with link and then decided to break it up in case it is required. As an afterthought, I left the link variable in there.

I am not sure what you mean by "looking exactly". I checked the output HTML and for all purposes, it looks exactly like before.

berdir’s picture

by "looking exactly" I meant how the template looks.

I'd prefer to go with just link in the template. no need to make it more complicated than it has to bre.

hussainweb’s picture

StatusFileSize
new365 bytes
new3.52 KB

Changing the twig file. Personally, I don't mind and yes, I don't see this being overridden, but you never know. :)

berdir’s picture

Status: Needs review » Fixed

Ok, this looks like a good improvement and step forward. Committed.

  • Berdir committed 3492abf on 8.x-1.x authored by hussainweb
    Issue #2641336 by hussainweb: Use twig for token tree link instead of...

Status: Fixed » Closed (fixed)

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