Problem/Motivation

Similar to #2226533: Changes to the Language class due to the LanguageInterface (followup)
or some things moved here from there.

Proposed resolution

Update docs to reference the Interface.

Remaining tasks

review.

User interface changes

No.

API changes

No.

Comments

yesct’s picture

+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php
@@ -109,10 +109,11 @@ public function isSyncing();
* entity change is part of an uninstall process, and skip executing your code
* if that is the case.
*
- * For example, \Drupal\language\Entity\ConfigurableLanguage::preDelete()
- * prevents the API from deleting the default language. However during an
- * uninstall of the language module it is expected that the default language
- * should be deleted.
+ * For example,
+ * \Drupal\language\Entity\ConfigurableLanguageInterface::preDelete() prevents
+ * the API from deleting the default language. However during an uninstall of
+ * the language module it is expected that the default language should be
+ * deleted.

yesct’s picture

taking out from #2226533: Changes to the Language class due to the LanguageInterface (followup)

diff --git a/core/modules/language/src/Entity/ConfigurableLanguage.php b/core/modules/language/src/Entity/ConfigurableLanguage.php
index eda4d9a..1a429c6 100644
--- a/core/modules/language/src/Entity/ConfigurableLanguage.php
+++ b/core/modules/language/src/Entity/ConfigurableLanguage.php
@@ -87,9 +87,9 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
* container using the language.default service in when the entity is saved.
* The value is set correctly when a language entity is created or loaded.
*
- * @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
- * @see \Drupal\language\Entity\ConfigurableLanguage::isDefault()
- * @see \Drupal\language\Entity\ConfigurableLanguage::setDefault()
+ * @see \Drupal\language\Entity\ConfigurableLanguageInterface::postSave()
+ * @see \Drupal\language\Entity\ConfigurableLanguageInterface::isDefault()
+ * @see \Drupal\language\Entity\ConfigurableLanguageInterface::setDefault()
*
* @var bool
*/
@@ -101,8 +101,8 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
* This property is not saved to the language entity, but is needed for
* detecting when to rebuild the services.
*
- * @see \Drupal\language\Entity\ConfigurableLanguage::preSave()
- * @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
+ * @see \Drupal\language\Entity\ConfigurableLanguageInterface::preSave()
+ * @see \Drupal\language\Entity\ConfigurableLanguageInterface::postSave()
*
* @var bool
*/
@@ -148,7 +148,7 @@ public function preSave(EntityStorageInterface $storage) {
parent::preSave($storage);
// Store whether or not the site is already multilingual so that we can
// rebuild services if necessary during
- // \Drupal\language\Entity\ConfigurableLanguage::postSave().
+ // \Drupal\language\Entity\ConfigurableLanguageInterface::postSave().
$this->preSaveMultilingual = \Drupal::languageManager()->isMultilingual();
// Languages are picked from a predefined list which is given in English.
// For the uncommon case of custom languages the label should be given in
@@ -319,4 +319,11 @@ public function setNegotiationMethodId($method_id) {
return $this;
}

+ /**
+ * {@inheritdoc}
+ */
+ public function isLocked() {
+ return !empty($this->locked);
+ }
+
}

I would have thought #2246679: Make Language module's LanguageInterface (to be ConfigurableLanguageInterface) extend Core's LanguageInterface would have taken care of this if it is needed.

look at the addition of isLocked() (later).

yesct’s picture

and... in LanguageConfigurationElementTest

@@ -99,7 +99,7 @@ public function testDefaultLangcode() {
$this->assertFalse($configurable_language->get('default'), 'The en language entity is not flagged as the default language.');
$configurable_language = entity_load('configurable_language', 'cc');
// Check calling the
- // \Drupal\language\Entity\ConfigurableLanguage::isDefault() method
+ // \Drupal\language\Entity\ConfigurableLanguageInterface::isDefault() method
// directly.
$this->assertTrue($configurable_language->isDefault(), 'The cc language entity is flagged as the default language.');

martin107’s picture

Status: Active » Needs review
StatusFileSize
new2.88 KB

So for the changes in the following comments.

#1 (I suggest skipping it) It only puts- " For example," on a new line .. very minor change - also inconsistent with other examples of inline "For example" elsewhere in file.

#2 in patch - NB. setDefault() has been removed. regarding isLocked() - I agree - skip it for now.

#3 in patch

yesct’s picture

Issue summary: View changes
StatusFileSize
new3.89 KB
new1.01 KB

#1 appeared to put For example on it's own, line, but really that was because adding Interface to the namespace made the line longer than 80 chars.

Let's still do this.
---
yeah, #2 [#9145521]

---
thought #2339435: Default no longer needs to be a property on Language or ConfigurableLanguage might effect things here. but maybe not.

yesct’s picture

yesct’s picture

Title: Changes to the ConfigurableLanguage class due to the ConfigurableLanguageInterface (followup) » Update comment references to the interface for ConfigurableLanguage class due to the ConfigurableLanguageInterface (followup)
StatusFileSize
new4.58 KB
new708 bytes

to see if caught all similar things, I did a grep/ag:
ag --literal "Entity\ConfigurableLanguage" core/*

look at

core/modules/language/src/Form/LanguageFormBase.php
52: /** @var $language \Drupal\language\Entity\ConfigurableLanguage */

updating that one.
while changing that line, rearranged the order of the @var so it works with more IDEs than just phpstorm.
--
I think this is good now.

--
in irc, @alexpott mentioned that the issue to make the ConfigurableLanguage properties protected should be ... #2226533: Changes to the Language class due to the LanguageInterface (followup).
hm.

.. changing the title since we wont make the properties protected in this issue.

gábor hojtsy’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +sprint

Looks good.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: -sprint
  1. +++ b/core/modules/language/src/Entity/ConfigurableLanguage.php
    @@ -90,8 +90,8 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
    -   * @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
    -   * @see \Drupal\language\Entity\ConfigurableLanguage::isDefault()
    +   * @see \Drupal\language\Entity\ConfigurableLanguageInterface::postSave()
    +   * @see \Drupal\language\Entity\ConfigurableLanguageInterface::isDefault()
    
    @@ -140,7 +140,7 @@ public function preSave(EntityStorageInterface $storage) {
    -    // \Drupal\language\Entity\ConfigurableLanguage::postSave().
    +    // \Drupal\language\Entity\ConfigurableLanguageInterface::postSave().
    

    These should point to the actual implementation since this property is for them and nothing to do with the interface methods.

  2. +++ b/core/modules/language/src/Entity/ConfigurableLanguage.php
    @@ -103,8 +103,8 @@ class ConfigurableLanguage extends ConfigEntityBase implements ConfigurableLangu
    -   * @see \Drupal\language\Entity\ConfigurableLanguage::preSave()
    -   * @see \Drupal\language\Entity\ConfigurableLanguage::postSave()
    +   * @see \Drupal\language\Entity\ConfigurableLanguageInterface::preSave()
    +   * @see \Drupal\language\Entity\ConfigurableLanguageInterface::postSave()
    

    This will conflict with #2339435: Default no longer needs to be a property on Language or ConfigurableLanguage but in theory also should not change for the same reasons as above.

alexpott’s picture

Issue tags: +sprint

Adding tag back

yesct’s picture

Status: Needs work » Needs review
StatusFileSize
new2.6 KB
new1.98 KB

Thanks.

I see, these are @see on a property on the class.
(note git diff -U10 gives more context lines)

Ah, and #2339435: Default no longer needs to be a property on Language or ConfigurableLanguage leaves in isDefault() ... but takes out the *property* that these are comments on.

Thanks for pointing that out.

Taking out those changes.

penyaskito’s picture

Issue tags: +Needs reroll, +Novice

Does not apply anymore.

penyaskito’s picture

Status: Needs review » Needs work

Oops

martin107’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new2.59 KB

Reroll. - No conflicts just auto merging.

mon_franco’s picture

Hi there,
I'm at the Amsterdam Sprint and i'm going to review this issue.

gábor hojtsy’s picture

Issue tags: +Amsterdam2014
mon_franco’s picture

StatusFileSize
new651 bytes
new2.97 KB

I have some doubts about the return (@return $this) of some functions. So I didn't change this kind of coder errors yet.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community
penyaskito’s picture

Issue summary: View changes

Talked with @YesCT, #17 change is out of scope, so let's leave that behind.
So the RTBC patch is #14.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityInterface.php
@@ -109,10 +109,11 @@ public function isSyncing();
-   * For example, \Drupal\language\Entity\ConfigurableLanguage::preDelete()
-   * prevents the API from deleting the default language. However during an
-   * uninstall of the language module it is expected that the default language
-   * should be deleted.
+   * For example,
+   * \Drupal\language\Entity\ConfigurableLanguageInterface::preDelete() prevents
+   * the API from deleting the default language. However during an uninstall of
+   * the language module it is expected that the default language should be
+   * deleted.

It is the actual implementation that prevents deleting the default language not the interface. I think this part of the change is incorrect.

yesct’s picture

thanks. sorry for missing that. reading that whole doc block that is clear. I'll make the change.

yesct’s picture

Status: Needs work » Needs review
StatusFileSize
new1.59 KB

oops. the order change in the /** @var */ was going away from the one more recognizable by more IDEs. #2305593: [policy] Set a standard for @var inline variable type declarations So left the order like it is in head.
also put back what @alexpott pointed out.

yesct’s picture

Status: Needs review » Needs work

and the interdiff.

and... while looking at the patch again, noticed that

+++ b/core/modules/language/src/Tests/LanguageConfigurationElementTest.php
@@ -95,7 +95,7 @@ public function testDefaultLangcode() {
-    // \Drupal\language\Entity\ConfigurableLanguage::isDefault() method

not
\Drupal\language\Entity\ConfigurableLanguageInterface
it is
\Drupal\language\ConfigurableLanguageInterface

doing that next.

yesct’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new1.58 KB
new919 bytes

updating issue summary about which patch to look at also.

penyaskito’s picture

Status: Needs review » Reviewed & tested by the community

I didn't knew #2305593: [policy] Set a standard for @var inline variable type declarations, I will keep that one in mind. Looked if I could change the template in phpstorm and didn't find it, but that's another story.

The patch makes perfect sense.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed d2cbadc and pushed to 8.0.x. Thanks!

  • alexpott committed d2cbadc on
    Issue #2337825 by YesCT, martin107, mon_franco: Update comment...
gábor hojtsy’s picture

Issue tags: -sprint

Good cleanup, thanks!

Status: Fixed » Closed (fixed)

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