Token module used to provide three theme hooks, each of which would call each other resulting in confusing and difficult to test/debug code. The theme hooks were:
- token_tree_link
- token_tree
- tree_table
Only token_tree_link has remained and it's usage has slightly changed. Earlier, modules would use the token_tree theme hook to render a link by passing in the dialog option. This was confusing and unnecessary, and now modules should directly use '#theme' => 'token_tree_link'. The dialog option, which did not do anything else, has been removed. The token_tree_link will always show the tree browser in a dialog.
Subsequently, the tree_table theme hook has been replaced with a render element. This render element can construct the tree table from the #token_tree property. This also meant that the token_tree theme hook was nothing more than a way to build a render array, which has been moved to the TreeBuilder service under buildRenderable and buildAllRenderable methods.
Example
Before:
// Add the token popup to the top of the fieldset.
$form['tokens'] = array(
'#theme' => 'token_tree',
'#token_types' => ['node'],
'#dialog' => TRUE,
);
After:
$form['tokens'] = array(
'#theme' => 'token_tree_link',
'#token_types' => ['node'],
);
There is also an example on how this is being updated at Metatag module: #2648752: Fix token tree browser theme callback.