Problem/Motivation
There a lot of places where we need the translation langcodes of an entity but in order to retrieve them we always do
array_keys($entity->getTranslationLanguages())
As we do not always need the language objects but only the language codes it would be useful to have a method returning only them.
Proposed resolution
New method TranslatableInterface::getTranslationLangcodes.
Remaining tasks
Review.
User interface changes
None.
API changes
New method TranslatableInterface::getTranslationLangcodes.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#25 | interdiff_16_25.txt | 594 bytes | Rishabh Vishwakarma |
#25 | 2844222-25.patch | 2.04 KB | Rishabh Vishwakarma |
| |||
#24 | 2844222-nr-bot.txt | 2.07 KB | needs-review-queue-bot |
#23 | interdiff_16_23.txt | 528 bytes | Rishabh Vishwakarma |
#23 | 2844222-23.patch | 2.08 KB | Rishabh Vishwakarma |
Issue fork drupal-2844222
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
hchonovComment #3
hchonovComment #7
borisson_I'm not sure if this is a BC break, if it doesn't this looks very good and I think that this is a useful new addition.
Comment #16
smustgrave CreditAttribution: smustgrave at Mobomo commentedRerolled for 9.5
Curious to see if it breaks anything but agree with #7 looks like a good change.
Comment #18
smustgrave CreditAttribution: smustgrave at Mobomo commentednew function should be typehinted.
Change record should be added also.
Should be simple for someone to do.
Comment #20
royalpinto007Comment #21
royalpinto007Comment #22
rishabh064 CreditAttribution: rishabh064 at OpenSense Labs for DrupalFit commentedI've added type hint in the new method as per the comment #18, please review.
Still need work for change record.
Comment #23
Rishabh Vishwakarma CreditAttribution: Rishabh Vishwakarma at OpenSense Labs for DrupalFit commentedTypehinted the new function as mentioned in #18.
Comment #24
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #25
Rishabh Vishwakarma CreditAttribution: Rishabh Vishwakarma at OpenSense Labs for DrupalFit commentedTypehinted the new function as mentioned in #18.
Comment #26
borisson_#[\ReturnTypeWillChange]
This tells us that the return type will be different soon. This is completely new code, so this is not the correct way to mark this.
It needs to be array, in both the interface and the implementation I think?