Problem/Motivation
We have
core/modules/language/src/ConfigurableLanguageManager.php
class ConfigurableLanguageManager extends LanguageManager implements ConfigurableLanguageManagerInterface {
Drupal\Core\Language\LanguageManager is in
core/lib/Drupal/Core/Language/LanguageManager.php
we can re-use that pattern to help reduce confusion around
Drupal\Core\Language\LanguageInterface
and
Drupal\language\LanguageInterface
by making it
Drupal\language\ConfigurableLanguageInterface
Sure, they are namespaced, but we already have a pattern of using naming like this, and this will help reduce confusion.
background
Split off from #2246679: Make Language module's LanguageInterface (to be ConfigurableLanguageInterface) extend Core's LanguageInterface.
2246679 had an *and* in the issue title which is a sign it might need to be split,
and also the rename would be helpful with (reviews of) #2246665: Typehint with Drupal\Core\Language\LanguageInterface instead Drupal\Core\Language\Language.
It can be done without being held up with discussions/work on the methods.
Proposed resolution
Rename Language module's LanguageInterface to ConfigurableLanguageInterface
Remaining tasks
- (done) git instructions for creating patch | Contributor task documentation for creating a patch
- (done see #47) Need to find the reference that documents the config file naming, to address the concern of @alexpott (see #27)
- Review patch to check it fixes the issue, the change is properly documented and for coding standards. Make sure patch stays within scope of just this issue. | Contributor task documentation for reviewing patch
User interface changes
No.
API changes
Yes.
- Rename Language module's LanguageInterface to ConfigurableLanguageInterface
- Rename Language module's Language to ConfigurableLanguage
Comment | File | Size | Author |
---|---|---|---|
#61 | ConfigurableLanguage-2271005-61.patch | 24.87 KB | alimac |
#61 | interdiff-2271005-56-61.txt | 3.52 KB | alimac |
#56 | ConfigurableLanguage-2271005-56.patch | 34.01 KB | alimac |
#56 | interdiff-2271005-53-56.txt | 1.77 KB | alimac |
#53 | ConfigurableLanguage-2271005-53.patch | 23.06 KB | martin107 |
Comments
Comment #1
YesCT CreditAttribution: YesCT commentedComment #2
martin107 CreditAttribution: martin107 commentedThere is lots of activity in this general area ... dont want to step on other toes! So I am working on this as we speak
Comment #3
martin107 CreditAttribution: martin107 commentedFamous last words "This is a trival patch to write"
BUT
It should bring clarity to whole raft of other language module issues
So I consider this very useful. ( hence the QuickFix )
locally test :-
1) LanguageUILanguageNegotiationTest.php
2) LanguageListTest.php
Time for testbot to take a look.
PS This also will cause a flurry of rerolls .. feel free to call on me and I will help with that
Comment #4
YesCT CreditAttribution: YesCT commentedI did a refactor too, to double check, since I thought there might be more changes...
but this is renaming just the interface, not the Language, so this is ok.
My patch matches @martin107's so that is good! (so no interdiff. the interdiff would be empty)
This is just formatted differently with git configured to show copies/renames instead of file deleted and added.
in .gitconfig
https://drupal.org/documentation/git/configure
has some more info. :)
Comment #5
martin107 CreditAttribution: martin107 commentedAfter a conversation with YesCT I have "feature creeped" this issue to also rename
\Drupal\language\Entity\Language
to be
\Drupal\language\Entity\ConfigurableLanguage
I have tried a few tests locally ... but as always await testbot to return a more definitive answer
( LanguageConfigurationElementTest + NodeAccessLanguageAwareCombinationTest )
I have formed my git diff with a '-M' to ease the review process.
I am about done for the day and will respond to any issues in the morning.
To aid review I am including a list of all the times Language.php as used in core
find . -name 'Language.php'
./core/lib/Drupal/Core/Language/Language.php
./core/lib/Drupal/Core/TypedData/Plugin/DataType/Language.php
./core/modules/language/lib/Drupal/language/Entity/Language.php ( <---* )
./core/modules/language/lib/Drupal/language/Plugin/Condition/Language.php
./core/modules/node/lib/Drupal/node/Plugin/views/field/Language.php
./core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/Language.php
./core/modules/user/lib/Drupal/user/Plugin/views/field/Language.php
./core/vendor/symfony/validator/Symfony/Component/Validator/Constraints/Language.php
*changed by this patch
I found this useful
Comment #6
YesCT CreditAttribution: YesCT commented#2271421: Rename Language module's Language to ConfigurableLanguage is a separate issue, so we can review/commit #4 here.
Comment #7
YesCT CreditAttribution: YesCT commentedre-uploading #4, so the testbot can retest that one if this gets rtbc'd.
Comment #8
tim.plunkettThis should be rolled into #2271421: Rename Language module's Language to ConfigurableLanguage. It is small, it changes the same lines, and
class Language extends ConfigEntityBase implements ConfigurableLanguageInterface
is confusing, while
class Language extends ConfigEntityBase implements LanguageInterface
and
class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLanguageInterface
makes sense
Comment #9
YesCT CreditAttribution: YesCT commentedOK. Thanks.
#5 was headed that way. this interdiff is from #5.
updated issue summary.
Comment #10
tstoecklerYup awesome.
We should fix those
use Drupal\language\Entity\ConfigurableLanguage as LanguageEntity
to just useConfigurableLanguage
directly in a follow-up.Not marking RTBC myself as such a fundamental change - even if it's "just" naming - should be signed off by @Gábor Hojtsy. Assigning for that purpose.
Comment #11
tstoecklerHehe, schizophrenic me...
Comment #12
Gábor HojtsyI think this new terminology makes sense. Block entities are also CustomBlock and not Block to avoid the confusion in terminology duplicity. I think the ConfigurableLanguage as LanguageEntity removal would be better done here instead of splitting up even more.
Also I am wondering how the other terminology elements line up with this. Eg. this patch kleeps the machine name of the entity as "language_entity", which I guess would be better be "configurable_language" no? Also the config prefix of "entity", etc. So while the change looks good in itself, it leaves several things as-is that gets more mixed-up terminology wise AFAIS.
Comment #13
YesCT CreditAttribution: YesCT commentedok. created #2271581: Use class name ConfigurableLanguage instead of the LanguageEntity from "ConfigurableLanguage as LanguageEntity" and marked it postponed on this.
--- cross post ---
oh.. I'll close that one duplicate.
And remove the Quick fix tag.
Comment #14
martin107 CreditAttribution: martin107 commentedregarding #10
Comment #15
martin107 CreditAttribution: martin107 commentedFollow up filedsorry for noise ... closing duplicate
Comment #16
martin107 CreditAttribution: martin107 commented@GaborHojtsy ... Hi Can I ask for clarification regarding #12
looking at language.module language_save() as an example are you saying the local variable $language_entity should change!
I have to say I disagree as at it root $language_entity is an entity
I would be grateful if you could clarify
Comment #17
mrjmd CreditAttribution: mrjmd commentedHere's my attempt at fixing the part in comment #10.
Comment #18
YesCT CreditAttribution: YesCT commentedinterdiff in #17 looks good. :)
Comment #19
martin107 CreditAttribution: martin107 commented+1 to #17 patch looks good
Comment #20
Gábor HojtsyYeah as I said above I think keeping the language_entity config entity name mixes up terminology quite a bit now that a configurable language is brought into the mix too. So I hoped we can align that terminology, eg. rename language_entity to configurable_language then, but I understand the scope may be too big for that. However that is very unlikely to happen after the beta, so I could see core committers would only accept this if there is some chance we can do the renames wholesale for the entity as well.
Comment #21
martin107 CreditAttribution: martin107 commentedI don't want to tread on anybodies toes...
So I won't personally recommend this, I will leave it to reviewers, who know better than I to comment. This is just to see what it would look like.
The next change is far from the "Wholesale" solution but restricts itself to changes within the scope of the existing patch.
I am active in another (see related - 2271611 ) issue and this will cause a reroll That issue is talking about the difficulties of naming things .. So I am happy to reroll
if this were to land first...
Comment #22
YesCT CreditAttribution: YesCT commentedcoming back to this.
patch on its way.
I can't decide if I should do a new refactor, or try to reroll.
might do both and compare the results.
Comment #23
YesCT CreditAttribution: YesCT commented1. might need to check comments in testDependencyInjectedNewLanguage()
2. I'm not sure about this in ConfigurableLanguage.php
maybe it should be:
Im really not sure about changing the label.
3. in #21
does not need to be changed because it's a Core Language that gets returned from getCurrentLanguage()
and $language_interface here is not referring to php "Interfaces" but to the language of the drupal user interface.
--
I'll do the $language_entity change next.
Comment #24
YesCT CreditAttribution: YesCT commentedA. #23 2. I renamed the id.
B. what about route patterns?
->will($this->returnValue(new Route('/admin/config/regional/language/edit/{language_entity}')));
I just guessed and tried it.
C. I wonder why language.module does not implement hook_ENTITY_TYPE_update()
---
summary, this is just a guess.
(taking a break for a few hours)
Comment #25
tstoecklerI think 'configurable_language_entity' is redundant, as there is no language entity that is not configurable. I.e. that fact that is an entity makes it configurable. I would prefer 'configurable_language'.
Comment #27
YesCT CreditAttribution: YesCT commentedok. this just replaces configurable_language_entity with configurable language
this should fail in the same ways as 24.
--
1.
if it helps, I used this to survey other entity ids
ag --before=1 --after=3 '\@ConfigEntityType' core
--
2.
@alexpott noted in irc
a.
that we might also want to consider the implications on config naming.
the config files for configurable languages are language.entity.*
but
the file has to start with language.ENTITY_IDENTIFIER.*
So, right now, I guess it's already not following that convention because they would have been language.language_entity.* ?
b.
Also, that we might not need this issue.. cause namespaces are supposed to allow us to have different things named the same.
Comment #29
martin107 CreditAttribution: martin107 commentedThis change makes Drupal\config_translation\Tests\ConfigTranslationOverviewTest pass locally
Comment #30
YesCT CreditAttribution: YesCT commentedthanks. dont know how I missed that one.
Comment #32
martin107 CreditAttribution: martin107 commentedPatch no longer applied, this is just a reroll. No conflicts just merging.
Comment #34
martin107 CreditAttribution: martin107 commentedI am just posting this as I can't run head at the moment and I am just off to bed ... I will try again in the morning
The entity_type needs changing the in the function of the form hook_ENTITY_TYPE_delete()
part of the solution, the interdiff from #32 I think but need to confirm
Comment #35
martin107 CreditAttribution: martin107 commentedThe morning light shows a seg fault on my apache server aghhh... so here is the fix ( see #34 )
Locally Drupal\block\Tests\BlockLanguageTest now passes.
Comment #37
martin107 CreditAttribution: martin107 commentedThis is just a natural extension of the fix from #34/35.
Comment #38
YesCT CreditAttribution: YesCT commentedopened #2315301: where core Language and language module Language were used in the same file take out the use core Language as LanguageObject and just call them Language to do that after this. should be straight forward.
is #1479492: [policy] Define standards for naming and granularity of config files still up to date on the config file name convention?
I could not find a doc page about it.
Comment #39
YesCT CreditAttribution: YesCT commentedupdated issue summary motivation for concerns that have been brought up along the way here.
Comment #40
dawehnerWe do have to update the routes names, as introduced by 2314875 now.
Isn't the relationship between language nad configurable_language similar to field_instance and field_instance_config. Did you thought about using that pattern?
Note: These hooks should actually use the interface. Fill a follow up.
Comment #41
martin107 CreditAttribution: martin107 commentedStraight reroll, first.
Comment #42
YesCT CreditAttribution: YesCT commentedlooks like that was for #2314875: Standardize language entity route names
and only in context lines.
is that correct?
Comment #43
martin107 CreditAttribution: martin107 commentedYes, going back and doing a file diff....
The only change I was conscious off was :-
but I see this also was a change
Comment #44
martin107 CreditAttribution: martin107 commentedJust coming back to look at this today ... all issues raised in #40 have been addressed as the patch was rerolled to match HEAD.
Comment #45
YesCT CreditAttribution: YesCT commented@dawehner re #40 2.
No, I had not looked at that for a model patter. I think it is a bit different though, because field instance config
class FieldInstanceConfig extends ConfigEntityBase implements FieldInstanceConfigInterface {
class Language extends ConfigEntityBase implements LanguageInterface {
hm.
there is no fieldinstance
interface FieldInstanceConfigInterface extends ConfigEntityInterface, FieldDefinitionInterface {
guess they are field definitions
in irc, @dawehner said...
mh maybe just ignore me, can't remember what I thought
so I think we are ok with this pattern. (the LanguageManager ConfigurableLanguageManager pattern)
Comment #46
YesCT CreditAttribution: YesCT commentedopened #2316561: type hint hooks with interface: ConfigurableLanguageInterface instead of LanguageEntity/ConfigurableLanguage for #40 point 3.
Comment #47
YesCT CreditAttribution: YesCT commentedRe @alexpott in #27 2a.
This encouraged me to find .. which lead to create a standards page for config files.
[edit: adding link to the standards page] https://www.drupal.org/coding-standards/config
During that with @jhodgdon, we have clarified that the standard for the file name is:
(extension).(config_prefix).(machinename)
extension is usually the module responsible for providing the thing,
and config_prefix is set on in the annotation, or defaults to entity_id
for language module Language, there is a config prefix set:
in
class Language extends ConfigEntityBase implements LanguageInterface {
the annotation has
* config_prefix = "entity",
so it is not defaulting to entity_id.
And so we do not need to change config filenames here.
If we do want to make them be entity_id, we can do that in a separate issue.
if we did, we would have to find any
config('language.entity')->get(whatever)
and change that code.
but I suspect there may be several entities that are specifying config_prefix, so we should *think* about if any of them should not do that and use the entity_id instead.
An example config file that would be effected would be:
core/modules/language/config/install/language.entity.en.yml
So, we do not need to rename config files.
Comment #48
martin107 CreditAttribution: martin107 commentedComment #49
YesCT CreditAttribution: YesCT commentedat tcdrupal. checked and it still applies. looking for a reviewer.
Comment #50
penyaskitoIt would be nice to use getId() here -there are some other-occurrences too-, but as this is blocking other issues, IMHO we should move forward and fill a follow-up.
Comment #51
martin107 CreditAttribution: martin107 commentedThe point from #50 will be addressed in the stalled issue https://www.drupal.org/node/2226533
which will one day get committed... honest!!!
Comment #52
alexpottWe have new standards on route names here... these should be
entity.configurable_language.*
now. See #2285413: [Meta] Standardize entity route namesComment #53
martin107 CreditAttribution: martin107 commentedApplied fix from #52.
Comment #55
penyaskito@martin107 You need to rename also in
core/modules/language/language.routing.yml
.Comment #56
alimac CreditAttribution: alimac commentedI renamed all instances of language_entity to configurable_language in
core/modules/language/language.routing.yml
.Comment #57
alimac CreditAttribution: alimac commentedComment #59
penyaskitoMissed this one.
Comment #60
alimac CreditAttribution: alimac commentedAh, yes. I found instances of language_entity routes in other places -- will post a patch and interdiff shortly.
Comment #61
alimac CreditAttribution: alimac commentedOK. Here is the updated patch for
core/modules/language/language.routing.yml
.I also used
grep -r language_entity ./* --exclude='*.patch'
to check if there were any other occurrences of language_entity routes:In phpStorm, I used Edit > Find > Replace in path to make the replacements.
Comment #62
penyaskitoAwesome, thanks!
Comment #63
alexpottCommitted 8a0fa31 and pushed to 8.0.x. Thanks!
https://www.drupal.org/node/2225341 needs an update
Comment #65
Les LimUpdated the existing change record: https://www.drupal.org/node/2225341/revisions/view/7074371/7520473