Problem/Motivation
OverviewTerms doesn't respect the current content language when building the form and term urls and names are generated based on the terms default language.
Proposed resolution
The entity manager is passed in the constructor, so we just have to keep a reference of it and when working with the terms first get the term in the language determined by the current context by executing:
$term = $this->entityManager->getTranslationFromContext($term);
.
The EntityManager service is deprecated and will be removed before Drupal 9.0.0 and the function getTranslationFromContext is provided by the EntityRepository service, but the constructor of OverviewTerms now has as a parameter the EntityManager service and to add another constructor parameter will be API break. To allow for the patch to get in 8.0.x or 8.1.x we still use the EntityManager service, which is already there instead of altering the constructor.
Remaining tasks
Write tests.
User interface changes
Terms and their urls are now pointing not to the default term language, but to the translation language determined by the current context.
API changes
none
Data model changes
none
Comment | File | Size | Author |
---|---|---|---|
#28 | interdiff-25-28.txt | 604 bytes | jofitz |
#28 | 2671058-28.patch | 3.05 KB | jofitz |
#25 | interdiff-22-25.txt | 602 bytes | jofitz |
#25 | 2671058-25.patch | 3.06 KB | jofitz |
#22 | interdiff19_22.txt | 1.62 KB | Munavijayalakshmi |
Comments
Comment #2
hchonovComment #3
hchonovComment #4
hchonovComment #5
hchonovComment #6
hchonovRerolling the patch as it could not be applied anymore because of a comment change made in #2471689: Entity API documentation should consistently refer to handlers rather than controllers.
Comment #8
hchonovComment #10
tstoecklerWe should have some tests for this.
Comment #12
pguillard CreditAttribution: pguillard commentedHere is a patch with a test
Comment #13
tstoecklerThe test looks great to me. Uploading a tests-only patch, to prove that it is correct.
Comment #15
tstoecklerPerfect! Thanks again.
Comment #17
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedarray() -> []
Comment #19
tameeshb CreditAttribution: tameeshb at Google Summer of Code commentedPatch rerolled
Comment #20
tstoecklerJust seeing this now, should have seen this earlier:
1. The method should have a public scope (i.e. put "publich function" instead of "function"
2. The method should have a docblock. Something like:
This should now use the short array syntax.
Comment #21
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedComment #22
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedComment #23
Munavijayalakshmi CreditAttribution: Munavijayalakshmi at Valuebound commentedComment #24
tstoecklerAhh sorry, missed one more coding standards error:
There should be an empty newline before the last closing brace (the one for the class)
Comment #25
jofitz CreditAttribution: jofitz at ComputerMinds commentedAdded newline.
Comment #26
hchonovThe whitespace should be removed :).
Comment #27
tstoecklerSorry, to be so annoying but the newline now contains trailing whitespace, can you please remove that?
Sorry, I promise I will RTBC the next patch. ;-) And yes, we really need better tools so that some of this stuff is automated, but we're getting there, at least we now have coding style checks on Drupal.org...
Comment #28
jofitz CreditAttribution: jofitz at ComputerMinds commentedI blame phpStorm! That is a sign I should go home for the night! White space removed.
Comment #29
tstoecklerWell, you should go home content, then. RTBC! Thanks a lot
Comment #30
alexpottCommitted and pushed d370ee7 to 8.4.x and 2008561 to 8.3.x. Thanks!
Nice find and nice test coverage.
Comment #35
xjmSorry, the revert here was an accident reverting another issue committed around the same time. It's un-reverted now (i.e. still fixed).