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

User interface changes

No.

API changes

Yes.

  • Rename Language module's LanguageInterface to ConfigurableLanguageInterface
  • Rename Language module's Language to ConfigurableLanguage
CommentFileSizeAuthor
#61 ConfigurableLanguage-2271005-61.patch24.87 KBalimac
#61 interdiff-2271005-56-61.txt3.52 KBalimac
#56 ConfigurableLanguage-2271005-56.patch34.01 KBalimac
#56 interdiff-2271005-53-56.txt1.77 KBalimac
#53 ConfigurableLanguage-2271005-53.patch23.06 KBmartin107
#53 interdiff-41-53.txt629 bytesmartin107
#41 ConfigurableLanguage-2271005-41.patch22.76 KBmartin107
#37 ConfigurableLanguage-2271005-37.patch22.67 KBmartin107
#37 interdiff-35-37.txt3.25 KBmartin107
#35 ConfigurableLanguage-2271005-34.patch22.63 KBmartin107
#35 interdiff-32.34.txt660 bytesmartin107
#32 ConfigurableLanguage-2271005-32.patch22.66 KBmartin107
#29 ConfigurableLanguage-2271005-29.patch22.75 KBmartin107
#29 interdiff-27.29.txt913 bytesmartin107
#27 interdiff.24.27.txt14.68 KBYesCT
#27 ConfigurableLanguage-2271005-27.patch21.85 KBYesCT
#24 interdiff.2246679.23.24.txt14.39 KBYesCT
#24 ConfigurableLanguage-2271005-24.patch22.2 KBYesCT
#23 ConfigurableLanguage-2271005-23.patch11.65 KBYesCT
#21 interdiff-17-21.txt4.65 KBmartin107
#21 ConfigurableLanguage-2271005-21.patch27.79 KBmartin107
#17 ConfigurableLanguage-2271005-17.patch23.32 KBmrjmd
#17 interdiff-2271005-9-16.txt4.35 KBmrjmd
#9 interdiff-2271005-5-9.txt1.91 KBYesCT
#9 ConfigurableLanguage-2271005-9.patch9.04 KBYesCT
#7 ConfigurableLanguageTest-2271005-4.patch1.74 KBYesCT
#5 interdiff-4-5.txt7.86 KBmartin107
#5 ConfigurableLanguageClass-2271005-5.patch9.04 KBmartin107
#4 ConfigurableLanguageTest-2271005-4.patch1.74 KBYesCT
#3 ConfigurableLanguageTest-2271005-3.patch2.05 KBmartin107
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

YesCT’s picture

Issue tags: +API change
martin107’s picture

Assigned: Unassigned » martin107

There is lots of activity in this general area ... dont want to step on other toes! So I am working on this as we speak

martin107’s picture

Status: Active » Needs review
Issue tags: +Quick fix
FileSize
2.05 KB

Famous 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

YesCT’s picture

I 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

[diff]
  renames = copy

https://drupal.org/documentation/git/configure
has some more info. :)

martin107’s picture

After 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

YesCT’s picture

YesCT’s picture

re-uploading #4, so the testbot can retest that one if this gets rtbc'd.

tim.plunkett’s picture

This 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

YesCT’s picture

Title: Rename Language module's LanguageInterface to ConfigurableLanguageInterface » Rename Language module's LanguageInterface to ConfigurableLanguageInterface and Language to ConfigurableLanguage
Issue summary: View changes
FileSize
9.04 KB
1.91 KB

OK. Thanks.

#5 was headed that way. this interdiff is from #5.

updated issue summary.

tstoeckler’s picture

Assigned: martin107 » Gábor Hojtsy
Status: Needs review » Reviewed & tested by the community

Yup awesome.

We should fix those use Drupal\language\Entity\ConfigurableLanguage as LanguageEntity to just use ConfigurableLanguage 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.

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs review

Hehe, schizophrenic me...

Gábor Hojtsy’s picture

Assigned: Gábor Hojtsy » Unassigned

I 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.

YesCT’s picture

ok. 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.

martin107’s picture

regarding #10

We should fix those use Drupal\language\Entity\ConfigurableLanguage as LanguageEntity to just use ConfigurableLanguage directly in a follow-up.

+1 That was on my mind as I converted things .... but erred on the size of minimal changes.

martin107’s picture

Follow up filed

sorry for noise ... closing duplicate

martin107’s picture

@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!

  $language_entity = entity_load('language_entity', $language->id);
  if (!$language_entity) {
    $language_entity = entity_create('language_entity', array(
      'id' => $language->id,
    ));
  }

I have to say I disagree as at it root $language_entity is an entity
I would be grateful if you could clarify

mrjmd’s picture

Status: Needs work » Needs review
FileSize
4.35 KB
23.32 KB

Here's my attempt at fixing the part in comment #10.

YesCT’s picture

interdiff in #17 looks good. :)

martin107’s picture

+1 to #17 patch looks good

Gábor Hojtsy’s picture

Yeah 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.

martin107’s picture

I 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...

YesCT’s picture

Status: Needs review » Needs work

coming 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.

YesCT’s picture

Status: Needs work » Needs review
FileSize
11.65 KB

1. might need to check comments in testDependencyInjectedNewLanguage()

2. I'm not sure about this in ConfigurableLanguage.php

  * @ConfigEntityType(
  *   id = "language_entity",
  *   label = @Translation("Language"),
  *   controllers = {

maybe it should be:

  * @ConfigEntityType(
  *   id = "configurable_language_entity",
  *   label = @Translation("Language"),
  *   controllers = {

Im really not sure about changing the label.

3. in #21

 function locale_get_plural($count, $langcode = NULL) {
-  $language_interface = \Drupal::languageManager()->getCurrentLanguage();
+  $configurableLanguage = \Drupal::languageManager()->getCurrentLanguage();

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.

YesCT’s picture

A. #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)

tstoeckler’s picture

I 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'.

Status: Needs review » Needs work

The last submitted patch, 24: ConfigurableLanguage-2271005-24.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
FileSize
21.85 KB
14.68 KB

ok. 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.

Status: Needs review » Needs work

The last submitted patch, 27: ConfigurableLanguage-2271005-27.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
913 bytes
22.75 KB

This change makes Drupal\config_translation\Tests\ConfigTranslationOverviewTest pass locally

YesCT’s picture

thanks. dont know how I missed that one.

Status: Needs review » Needs work

The last submitted patch, 29: ConfigurableLanguage-2271005-29.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
22.66 KB

Patch no longer applied, this is just a reroll. No conflicts just merging.

Status: Needs review » Needs work

The last submitted patch, 32: ConfigurableLanguage-2271005-32.patch, failed testing.

martin107’s picture

I 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

  *
  * Delete the potential block visibility settings of the deleted language.
  */
-function block_language_entity_delete(ConfigurableLanguage $language) {
+function block_configurable_language_delete(ConfigurableLanguage $language) {
   // Remove the block visibility settings for the deleted language.
martin107’s picture

Status: Needs work » Needs review
FileSize
660 bytes
22.63 KB

The 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.

Status: Needs review » Needs work

The last submitted patch, 35: ConfigurableLanguage-2271005-34.patch, failed testing.

martin107’s picture

Status: Needs work » Needs review
FileSize
3.25 KB
22.67 KB

This is just a natural extension of the fix from #34/35.

YesCT’s picture

YesCT’s picture

Issue summary: View changes

updated issue summary motivation for concerns that have been brought up along the way here.

dawehner’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php
    @@ -57,14 +57,14 @@ public function setUp() {
           'names' => array(),
    -      'entity_type' => 'language_entity',
    +      'entity_type' => 'configurable_language',
    

    We do have to update the routes names, as introduced by 2314875 now.

  2. +++ b/core/modules/config_translation/tests/src/ConfigEntityMapperTest.php
    @@ -101,7 +101,7 @@ public function testSetEntity() {
    -      ->with('language_entity')
    +      ->with('configurable_language')
    

    Isn't the relationship between language nad configurable_language similar to field_instance and field_instance_config. Did you thought about using that pattern?

  3. +++ b/core/modules/locale/locale.module
    @@ -222,9 +222,9 @@ function locale_stream_wrappers() {
    -function locale_language_entity_insert(LanguageEntity $language) {
    +function locale_configurable_language_insert(ConfigurableLanguage $language) {
    
    @@ -233,9 +233,9 @@ function locale_language_entity_insert(LanguageEntity $language) {
    -function locale_language_entity_update(LanguageEntity $language) {
    +function locale_configurable_language_update(ConfigurableLanguage $language) {
    

    Note: These hooks should actually use the interface. Fill a follow up.

martin107’s picture

Status: Needs work » Needs review
FileSize
22.76 KB

Straight reroll, first.

YesCT’s picture

looks like that was for #2314875: Standardize language entity route names
and only in context lines.

is that correct?

martin107’s picture

Yes, going back and doing a file diff....

The only change I was conscious off was :-

<        'route_name' => 'config_translation.item.overview.language.edit',
---
>        'route_name' => 'config_translation.item.overview.entity.language_entity.edit_form',

but I see this also was a change

<        ->with('language.edit')
---
>        ->with('entity.language_entity.edit_form')
martin107’s picture

Just coming back to look at this today ... all issues raised in #40 have been addressed as the patch was rerolled to match HEAD.

YesCT’s picture

@dawehner re #40 2.

Isn't the relationship between language nad configurable_language similar to field_instance and field_instance_config. Did you thought about using that pattern?

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)

YesCT’s picture

YesCT’s picture

Re @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.

martin107’s picture

Issue summary: View changes
YesCT’s picture

Issue tags: +TCDrupal 2014

at tcdrupal. checked and it still applies. looking for a reviewer.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/core/modules/language/language.module
@@ -414,21 +414,21 @@ function language_get_default_langcode($entity_type, $bundle) {
+  $configurable_language = entity_load('configurable_language', $language->id);

It 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.

martin107’s picture

The point from #50 will be addressed in the stalled issue https://www.drupal.org/node/2226533
which will one day get committed... honest!!!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
 *   links = {
 *     "delete-form" = "entity.language_entity.delete_form",
 *     "edit-form" = "entity.language_entity.edit_form"
 *   }

We have new standards on route names here... these should be entity.configurable_language.* now. See #2285413: [Meta] Standardize entity route names

martin107’s picture

Status: Needs work » Needs review
FileSize
629 bytes
23.06 KB

Applied fix from #52.

Status: Needs review » Needs work

The last submitted patch, 53: ConfigurableLanguage-2271005-53.patch, failed testing.

penyaskito’s picture

@martin107 You need to rename also in core/modules/language/language.routing.yml.

alimac’s picture

I renamed all instances of language_entity to configurable_language in core/modules/language/language.routing.yml.

alimac’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 56: ConfigurableLanguage-2271005-56.patch, failed testing.

penyaskito’s picture

+++ b/core/modules/language/language.routing.yml
@@ -25,34 +25,34 @@ language.negotiation_selected:
 entity.language_entity.edit_form:
-  path: '/admin/config/regional/language/edit/{language_entity}'
+  path: '/admin/config/regional/language/edit/{configurable_language}'

Missed this one.

alimac’s picture

Ah, yes. I found instances of language_entity routes in other places -- will post a patch and interdiff shortly.

alimac’s picture

Status: Needs work » Needs review
FileSize
3.52 KB
24.87 KB

OK. 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:

./core/modules/config_translation/tests/src/ConfigEntityMapperTest.php:      ->with('entity.language_entity.edit_form')
./core/modules/config_translation/tests/src/ConfigEntityMapperTest.php:      'base_route_name' => 'entity.language_entity.edit_form',
./core/modules/config_translation/tests/src/ConfigEntityMapperTest.php:      'route_name' => 'config_translation.item.overview.entity.language_entity.edit_form',
./core/modules/language/language.links.task.yml:entity.language_entity.edit_form:
./core/modules/language/language.links.task.yml:  route_name: entity.language_entity.edit_form
./core/modules/language/language.links.task.yml:  base_route: entity.language_entity.edit_form
./core/modules/language/tests/src/Menu/LanguageLocalTasksTest.php:    $this->assertLocalTasks('entity.language_entity.edit_form', array(
./core/modules/language/tests/src/Menu/LanguageLocalTasksTest.php:      0 => array('entity.language_entity.edit_form'),

In phpStorm, I used Edit > Find > Replace in path to make the replacements.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, thanks!

alexpott’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +Needs change record updates

Committed 8a0fa31 and pushed to 8.0.x. Thanks!

https://www.drupal.org/node/2225341 needs an update

  • alexpott committed 8a0fa31 on 8.0.x
    Issue #2271005 by martin107, YesCT, alimac, mrjmd: Rename Language...
Les Lim’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.