Follow up for #1869250-37: Various EntityNG and TypedData API improvements

Problem/Motivation

Config\Entity only overrides selective Entity\Entity methods thus far - these methods appear to be identical and not overridden.

Proposed resolution

Remove them.

Remaining tasks

User interface changes

None.

API changes

None.

Original report by @sun

From: #1869250-37: Various EntityNG and TypedData API improvements

+++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php
@@ -126,4 +127,53 @@ public function getExportProperties() {
+  public function getBCEntity() {
...
+  public function getOriginalEntity() {
...
+  public function getName() {
...
+  public function getRoot() {
...
+  public function getPropertyPath() {
...
+  public function getParent() {

Config\Entity only overrides selective Entity\Entity methods thus far - these methods appear to be identical and not overridden in any way; was there any reason to duplicate them?

We can remove them in a follow-up patch though - no reason to hold up the commit for that.

Comments

fago’s picture

Title: remove duplicated functions from Various EntityNG and TypedData API improvements » Rename getOriginalEntity and remove duplicated functions from ConfigEntityBase
Status: Active » Needs review
StatusFileSize
new4.75 KB

ok, I'd suggest renaming getOriginalEntity() to getNGEntity(). While the name isn't nice, it's clear what you get and the method is part of the BC-layer code. Anyway, it's just there temporary, but we should avoid possible confusions with $entity->original.

fago’s picture

Title: Rename getOriginalEntity and remove duplicated functions from ConfigEntityBase » Rename getOriginalEntity() and remove duplicated functions from ConfigEntityBase

Status: Needs review » Needs work

The last submitted patch, d8_cleanup.patch, failed testing.

fago’s picture

Status: Needs work » Postponed

oh - this doesn't apply as long #1778178: Convert comments to the new Entity Field API isn't committed. Let's get the other one in first.

fago’s picture

Status: Postponed » Active
fago’s picture

Status: Active » Needs review
StatusFileSize
new4.75 KB

ok, re-rolled the patch.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Just a question.. in the glorious future when the letters "NG" are eradicated from the D8 code base... will we still call this "getEntity"? Or will it be "getOriginalEntity"? If so, it seems like we need to keep "Original" in the name.

fago’s picture

Status: Needs review » Reviewed & tested by the community

will we still call this "getEntity"? Or will it be "getOriginalEntity"

Nope, as then the BC-mode will be removed, those two helpers for switching between the NG and the BC entity will go away as well. I hope that answers your question.

fago’s picture

#6: d8_cleanup.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work
Issue tags: +Novice, +Entity Field API, +typed data

The last submitted patch, d8_cleanup.patch, failed testing.

yesct’s picture

Issue tags: +Needs reroll

this might be a good Novice one for the sprints coming up.
reroll doc: http://drupal.org/patch/reroll

Gaelan’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new4.75 KB

Rerolled.

yesct’s picture

added \ in
Implements \Drupal...
to be consistant with surrounding code and also with http://drupal.org/node/1354#file

aside from that, it looked good to me.

Also updating issue summary.

yesct’s picture

Issue summary: View changes

added html code tag to add clarity

fago’s picture

berdir’s picture

Patch makes sense but we should wait until after the node NG issue is in, will require a ton more renames after that and it's finally RTBC.

das-peter’s picture

berdir’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Novice, -typed data

I thought there would be more of those but I guess most ore getBCEntity().

Looks good, back to RTBC.

berdir’s picture

Issue tags: +Novice, +typed data

Re-adding lost terms.

yesct’s picture

I looked at the coding style and it looks good to me too.
(retesting to keep it fresh for commit)

yesct’s picture

tim.plunkett’s picture

StatusFileSize
new9.75 KB

Didn't apply, because before #1446382: Need a reliable way to determine if a specific bundle for an entity type is translatable EntityInterface::getOriginalEntity() was at the end of the file.

Status: Reviewed & tested by the community » Needs work
Issue tags: -Novice, -Entity Field API, -typed data

The last submitted patch, entity-1877638-22.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
Issue tags: +Novice, +Entity Field API, +typed data

#22: entity-1877638-22.patch queued for re-testing.

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Was a random failure about a misisng table, back to RTBC.

xjm’s picture

#22: entity-1877638-22.patch queued for re-testing.

xjm’s picture

Issue tags: +Quick fix
berdir’s picture

#22: entity-1877638-22.patch queued for re-testing.

Status: Reviewed & tested by the community » Needs work
Issue tags: +Quick fix, +Novice, +Entity Field API, +typed data

The last submitted patch, entity-1877638-22.patch, failed testing.

smiletrl’s picture

Status: Needs work » Needs review
StatusFileSize
new9.79 KB

rerolled

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, looks good.

webchick’s picture

Not moving down from RTBC, but no, #9 didn't really answer my question.

Let's fast-forward to 3 months from now or whatever when BC no longer exists. That means NG also doesn't exist, because NG just is "the entity system."

That means we're going to have to rename this function again at some point down the road. What I was asking is therefore whether or not that function will be renamed at that point to "getEntity" or to "getOriginalEntity." If the latter, we're losing important semantic information. And either way, can we not just rename it to that already right now, and leave "BC" in the old stupid one that will eventually be removed?

berdir’s picture

This function will be removed together with getBCEntity(), it's the counterpiece to it to get the NG entity object when you have the BC decorator. When we remove the BC decorator we'll also remove this method as there will be no use case for it anymore :)

But until then, getNGEntity() makes more sense than getOriginalEntity() which has nothing to do with $entity->original that we have from 7.x and might become getOriginalEntity() or something like that.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Ah-ha. Okie doke then!

Committed and pushed to 8.x. Thanks.

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

Anonymous’s picture

Issue summary: View changes

updated to indicate write patch no longer a remaining task.