Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Status: Active » Needs review
FileSize
17.86 KB

Something like this.

Status: Needs review » Needs work

The last submitted patch, node-2015123-1.patch, failed testing.

tim.plunkett’s picture

Issue tags: +Entity Field API

Tagging

Berdir’s picture

Issue tags: -Entity Field API
+++ b/core/modules/node/lib/Drupal/node/NodeInterface.phpundefined
@@ -14,4 +14,59 @@
+  /**
+   * The node comment status indicator.
+   *
+   * COMMENT_NODE_HIDDEN => no comments
+   * COMMENT_NODE_CLOSED => comments are read-only
+   * COMMENT_NODE_OPEN => open (read/write)
+   *
+   * @var int
+   */
+  public function getComment();

Maybe leave this out because I really hope this will become a configurable field.

+++ b/core/modules/node/lib/Drupal/node/NodeInterface.phpundefined
@@ -14,4 +14,59 @@
+  public function getUid();

For FileInterface, we chose getOwner() that returns the loaded user entity. How many use cases do we have that just want the uid and loading the user would be an overhead? Then maye have getOwner() (author?) and getOwnerId()?

+++ b/core/modules/node/lib/Drupal/node/NodeInterface.phpundefined
@@ -14,4 +14,59 @@
+  public function isPublished();

In FileInterface, I also added methods to change the status, could be publish() here.

Berdir’s picture

Re-adding tags.

This is what I wanted to do for #1939994: Complete conversion of nodes to the new Entity Field API because it means we can convert all these so that it does no longer matter if we're working with an BC Decorator or not. Then we can convert to methods and only have to deal with the configurable fields (of which there's still going to be a ton, but..) when finally removing it.

xjm’s picture

Berdir’s picture

Status: Needs work » Needs review
FileSize
24.08 KB

Continuing a bit with this, added getAuthor() and getAuthorId() instead of getUid(), getCreatedTime() and getChangedTime(), removed the fake public properties, fixed some bugs in the conversions.

Also had some merge conflicts, so no useful interdiff.

Status: Needs review » Needs work

The last submitted patch, node-2015123-7.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
2.59 KB
23.65 KB

That should fix (most?) of those errors, also removed getComment as suggested above, we can still add it back.

Status: Needs review » Needs work

The last submitted patch, node-2015123-9.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
23.35 KB

Re-roll.

Status: Needs review » Needs work

The last submitted patch, node-interface-methods-2015123-11.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
23.58 KB

Merge resulted in two getBCEntity() methods.

Status: Needs review » Needs work

The last submitted patch, node-interface-methods-2015123-13.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
826 bytes
22.95 KB

Weeeeird.

twistor’s picture

Can we move the getAuthor() and getAuthorID() methods to an EntityAuthorInterface? Then Comment could implement it as well as contrib entities.

I'd be happy to do it in a followup.

Berdir’s picture

Title: Expand NodeInterface to provide getters » Expand NodeInterface to provide getters and setters
Status: Needs review » Needs work

I'm not sure about splitting interfaces up too much, I think it makes it harder to understand what methods are available when looking at documentation (IDE's don't have a problem with it except you don't have the node specific methods bold anymore).

Let's also add setter methods and then get this in and continue to convert to the interface in #1939994: Complete conversion of nodes to the new Entity Field API.

Berdir’s picture

Status: Needs work » Needs review
FileSize
24.72 KB

Ok, added some setter methods, not sure about some names. publish/unpublish works, stick/unstick and promote/unpromote not as much. Should we go for setSticky(TRUE/FALSE) there?

Status: Needs review » Needs work
Issue tags: -DX (Developer Experience), -Entity Field API, -Field API NG blocker

The last submitted patch, node-interface-methods-2015123-18.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
Issue tags: +DX (Developer Experience), +Entity Field API, +Field API NG blocker
Crell’s picture

+++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php
@@ -310,5 +141,116 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr
+    $this->set('promoted', NODE_PROMOTED);

Possible scope creep: NODE_PROMOTED should really be NodeInterface::PROMOTED. Same for the other constants here.

(Feel free to ignore for scope reasons, but it should be a follow up if possible.)

+++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php
@@ -310,5 +141,116 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr
+  /**
+   * {@inheritdoc}
+   */
+  public function stick() {
+    $this->set('sticky', NODE_STICKY);
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function unstick() {
+    $this->set('sticky', NODE_NOT_STICKY);
+  }

setSticky(TRUE/FALSE) definitely works better for me. I'd be fine with setPublished(TRUE/FALSE) as well if it makes sense for consistency.

Berdir’s picture

I'd like to postpone the constant changes. Because we use those methods as much as possible, most usages of them should go away, except probably queries. There might also be a discussion whether they should be on NodeInterface or Node.

Changed to setSticky(), setPromoted() and setPublished(), like the consistency argument.

Status: Needs review » Needs work

The last submitted patch, node-interface-methods-2015123-22.patch, failed testing.

Xano’s picture

+++ b/core/modules/node/lib/Drupal/node/NodeBCDecorator.php
@@ -13,4 +13,96 @@
+    $this->decorated->setAuthrorId($uid);

Typo: authRor

Berdir’s picture

Status: Needs work » Needs review
FileSize
3.61 KB
26.53 KB

Thanks, fixed that and also converted a few additional calls.

Status: Needs review » Needs work

The last submitted patch, node-interface-methods-2015123-25.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
524 bytes
26.55 KB

Hm, BC fun. Let's see if this works better.

Status: Needs review » Needs work

The last submitted patch, node-interface-methods-2015123-27.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
1.64 KB
26.96 KB

Added special handling for uid 0. Maybe the entityreference field should be improved instead. It doesn't seem to try to load the uid 0.

Xano’s picture

I did a manual review and apart from a few overly verbose @param and @return descriptions, the only things I found were three properties that have been removed, but do not seem to get equivalent methods in return, or have them already.

+++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php
@@ -60,175 +60,6 @@
-   * The node translation set ID.
-   *
-   * Translations sets are based on the ID of the node containing the source
-   * text for the translation set.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */

There is no equivalent.

+++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php
@@ -60,175 +60,6 @@
-   * The node revision creation timestamp.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $revision_timestamp;

There is no equivalent for this.

+++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php
@@ -60,175 +60,6 @@
-  /**
-   * The node revision author's user ID.
-   *
-   * @var \Drupal\Core\Entity\Field\FieldInterface
-   */
-  public $revision_uid;

There is no equivalent for this.

Berdir’s picture

Added methods for the revision stuff, leaving translation set ID out for now, that does not belong in here IMHO, translation.module stuff.

Also made the setters support fluent calls.

Status: Needs review » Needs work

The last submitted patch, node-interface-methods-2015123-31.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
570 bytes
34.95 KB

Fixing stupid typos. Making lots of them today.

Status: Needs review » Needs work
Issue tags: -DX (Developer Experience), -Entity Field API, -Field API NG blocker

The last submitted patch, node-interface-methods-2015123-33.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, node-interface-methods-2015123-33.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
Issue tags: +DX (Developer Experience), +Entity Field API, +Field API NG blocker
tim.plunkett’s picture

Status: Needs review » Reviewed & tested by the community

This is awesome, especially the fluent methods.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Needs a reroll

curl https://drupal.org/files/node-interface-methods-2015123-33.patch | git a
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 35784  100 35784    0     0  12333      0  0:00:02  0:00:02 --:--:-- 13317
error: patch failed: core/modules/node/node.module:375
error: core/modules/node/node.module: patch does not apply
Berdir’s picture

Status: Needs work » Needs review
FileSize
34.72 KB

Re-rolled.

plach’s picture

Status: Needs review » Reviewed & tested by the community

Green, back to RTBC.

alexpott’s picture

Title: Expand NodeInterface to provide getters and setters » Change notice: Expand NodeInterface to provide getters and setters
Priority: Normal » Critical
Status: Reviewed & tested by the community » Active
Issue tags: +Needs change record

Committed 083ee68 and pushed to 8.x. Thanks!

Berdir’s picture

Title: Change notice: Expand NodeInterface to provide getters and setters » Expand NodeInterface to provide getters and setters
Priority: Critical » Normal
Status: Active » Fixed
Issue tags: -Needs change record

Added this issue to https://drupal.org/node/1806650, which already describes that interfaces have been added and links to the Node interface.

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

Anonymous’s picture

Issue summary: View changes

simplify summary, the summary of the meta should be enough.