summaryrefslogtreecommitdiffstats
path: root/core/modules/node/src/Entity/Node.php
diff options
context:
space:
mode:
authorAlex Pott2017-04-18 13:34:08 +0100
committerAlex Pott2017-04-18 13:47:45 +0100
commit8938ab29067a633f5dbb40203e02af377def3eb6 (patch)
tree2a24c3c709f611e5473dd86acd416d987d6495b7 /core/modules/node/src/Entity/Node.php
parentdcec8637914897589f9e0c736b71d5169e7ccfc7 (diff)
Issue #2825973 by amateescu, timmillwood, himanshu-dixit, dawehner, Berdir, Wim Leers: Introduce a EditorialContentEntityBase class for revisionable and publishable entity types
Diffstat (limited to 'core/modules/node/src/Entity/Node.php')
-rw-r--r--core/modules/node/src/Entity/Node.php94
1 files changed, 2 insertions, 92 deletions
diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php
index c11a188..b66628c 100644
--- a/core/modules/node/src/Entity/Node.php
+++ b/core/modules/node/src/Entity/Node.php
@@ -2,9 +2,7 @@
namespace Drupal\node\Entity;
-use Drupal\Core\Entity\ContentEntityBase;
-use Drupal\Core\Entity\EntityChangedTrait;
-use Drupal\Core\Entity\EntityPublishedTrait;
+use Drupal\Core\Entity\EditorialContentEntityBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
@@ -79,10 +77,7 @@ use Drupal\user\UserInterface;
* }
* )
*/
-class Node extends ContentEntityBase implements NodeInterface {
-
- use EntityChangedTrait;
- use EntityPublishedTrait;
+class Node extends EditorialContentEntityBase implements NodeInterface {
/**
* Whether the node is being previewed or not.
@@ -286,21 +281,6 @@ class Node extends ContentEntityBase implements NodeInterface {
/**
* {@inheritdoc}
*/
- public function getRevisionCreationTime() {
- return $this->get('revision_timestamp')->value;
- }
-
- /**
- * {@inheritdoc}
- */
- public function setRevisionCreationTime($timestamp) {
- $this->set('revision_timestamp', $timestamp);
- return $this;
- }
-
- /**
- * {@inheritdoc}
- */
public function getRevisionAuthor() {
return $this->getRevisionUser();
}
@@ -308,13 +288,6 @@ class Node extends ContentEntityBase implements NodeInterface {
/**
* {@inheritdoc}
*/
- public function getRevisionUser() {
- return $this->get('revision_uid')->entity;
- }
-
- /**
- * {@inheritdoc}
- */
public function setRevisionAuthorId($uid) {
$this->setRevisionUserId($uid);
return $this;
@@ -323,47 +296,8 @@ class Node extends ContentEntityBase implements NodeInterface {
/**
* {@inheritdoc}
*/
- public function setRevisionUser(UserInterface $user) {
- $this->set('revision_uid', $user);
- return $this;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getRevisionUserId() {
- return $this->get('revision_uid')->entity->id();
- }
-
- /**
- * {@inheritdoc}
- */
- public function setRevisionUserId($user_id) {
- $this->set('revision_uid', $user_id);
- return $this;
- }
-
- /**
- * {@inheritdoc}
- */
- public function getRevisionLogMessage() {
- return $this->get('revision_log')->value;
- }
-
- /**
- * {@inheritdoc}
- */
- public function setRevisionLogMessage($revision_log_message) {
- $this->set('revision_log', $revision_log_message);
- return $this;
- }
-
- /**
- * {@inheritdoc}
- */
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
- $fields += static::publishedBaseFieldDefinitions($entity_type);
$fields['title'] = BaseFieldDefinition::create('string')
->setLabel(t('Title'))
@@ -455,30 +389,6 @@ class Node extends ContentEntityBase implements NodeInterface {
])
->setDisplayConfigurable('form', TRUE);
- $fields['revision_timestamp'] = BaseFieldDefinition::create('created')
- ->setLabel(t('Revision timestamp'))
- ->setDescription(t('The time that the current revision was created.'))
- ->setRevisionable(TRUE);
-
- $fields['revision_uid'] = BaseFieldDefinition::create('entity_reference')
- ->setLabel(t('Revision user ID'))
- ->setDescription(t('The user ID of the author of the current revision.'))
- ->setSetting('target_type', 'user')
- ->setRevisionable(TRUE);
-
- $fields['revision_log'] = BaseFieldDefinition::create('string_long')
- ->setLabel(t('Revision log message'))
- ->setDescription(t('Briefly describe the changes you have made.'))
- ->setRevisionable(TRUE)
- ->setDefaultValue('')
- ->setDisplayOptions('form', [
- 'type' => 'string_textarea',
- 'weight' => 25,
- 'settings' => [
- 'rows' => 4,
- ],
- ]);
-
$fields['revision_translation_affected'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Revision translation affected'))
->setDescription(t('Indicates if the last edit of a translation belongs to current revision.'))