Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
token system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
13 Apr 2013 at 13:22 UTC
Updated:
29 Jul 2014 at 22:10 UTC
Jump to comment: Most recent file
Comments
Comment #1
dave reidService probably makes sense since we'd want to inject the ModuleHandler and eventually caching as well.
Comment #2
xanoYep, that's what I realized: they're not mutually exclusive.
Comment #3
ParisLiakos commentedtagging
Comment #4
xanoComment #6
dave reid- If we're using a service, we can't use static methods anymore. Needs to be all regular function calls.
- Needs to be registered at /Drupal::Token for shorthand and DX
Comment #7
xanoFixed all of the above, and the installation failure, and re-tagging.
Comment #9
xanoComment #11
dave reidUsing __FUNCTION__ here means that this static will be stored as 'info' which is not desired. We should manually use 'token_info' as the static key instead of __FUNCTION__ until we replace this with injected caching.
Comment #12
dave reidCrazy thought, what if instead of having to declare \Drupal::token() in every instance of hook_tokens and hook_tokens_alter(), what if we passed $this into the hook as well?
Comment #13
xanoInteresting. I'm not sure whether it will actually improve DX, as most implementations will need other services as well, but it should be worth checking out. We'll need to do this in a follow-up issue, though.
The patch fixes the drupal_static(__FUNCTION__) issue, and a problem in a Views test which was caused by naming collisions. I opted to refer to the token service using $token_service rather than $token.
Comment #14
xanoComment #15
xanoToken::info() should be explicitly made public.
Comment #16
xanoToken::info() is now public. No other changes.
Comment #18
xano#16: drupal_1969540_04.patch queued for re-testing.
Re-testing, as the failed test passed locally and it seems like an unrelated issue.
Comment #19
ParisLiakos commentedlooks very good to me:)
just one biggie and two minors
why not turn this into a class property? Then we could unit test it
should be public function
No need to prefix Drupal in procedural, non namespaced code
Comment #20
xanoThis patch addresses those issues. It adds Token:setInfo() and Token::resetInfo() methods, and renames Token::info() to Token::getInfo().
Comment #22
xanoComment #23
ParisLiakos commentedThanks! looks really good now:)
we dont do this elsewhere in core.
protected $moduleHandler;
should be enough
same here..you can completely remove the @return
besides those this seems ready to fly, good job!
Comment #24
xanoComment #25
ParisLiakos commentedComment #26
alexpottAttaching the diff with all whitespace changes removed of the new Token class and token.inc... all changes look good to me. And this patch completely converts all usages. Nice!
Committed c014519 and pushed to 8.x.Thanks!
Comment #27
xanoThe token API is a service.
Comment #29
xanoComment #30
xjmUntagging. Please remove the tag when the change notification task is completed.