summaryrefslogtreecommitdiffstats
path: root/core/modules/node/src/Entity/Node.php
diff options
context:
space:
mode:
authorNathaniel Catchpole2016-10-20 13:33:59 +0100
committerNathaniel Catchpole2016-10-20 13:33:59 +0100
commit6ddd0ba55c676b051cf4cc3f68599ea8cc09326f (patch)
treee8c3cbda71d9606d30b736336943a9a45b9a2123 /core/modules/node/src/Entity/Node.php
parentaed10c0f69bd934049c99e2f847b5717d1e3ba3a (diff)
Issue #2810381 by timmillwood, plach: Add generic status field to ContentEntityBase
Diffstat (limited to 'core/modules/node/src/Entity/Node.php')
-rw-r--r--core/modules/node/src/Entity/Node.php24
1 files changed, 3 insertions, 21 deletions
diff --git a/core/modules/node/src/Entity/Node.php b/core/modules/node/src/Entity/Node.php
index bdb8050..d4e4715 100644
--- a/core/modules/node/src/Entity/Node.php
+++ b/core/modules/node/src/Entity/Node.php
@@ -4,6 +4,7 @@ namespace Drupal\node\Entity;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait;
+use Drupal\Core\Entity\EntityPublishedTrait;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
@@ -73,6 +74,7 @@ use Drupal\user\UserInterface;
class Node extends ContentEntityBase implements NodeInterface {
use EntityChangedTrait;
+ use EntityPublishedTrait;
/**
* Whether the node is being previewed or not.
@@ -242,20 +244,6 @@ class Node extends ContentEntityBase implements NodeInterface {
$this->set('sticky', $sticky ? NODE_STICKY : NODE_NOT_STICKY);
return $this;
}
- /**
- * {@inheritdoc}
- */
- public function isPublished() {
- return (bool) $this->getEntityKey('status');
- }
-
- /**
- * {@inheritdoc}
- */
- public function setPublished($published) {
- $this->set('status', $published ? NODE_PUBLISHED : NODE_NOT_PUBLISHED);
- return $this;
- }
/**
* {@inheritdoc}
@@ -367,6 +355,7 @@ class Node extends ContentEntityBase implements NodeInterface {
*/
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'))
@@ -408,13 +397,6 @@ class Node extends ContentEntityBase implements NodeInterface {
))
->setDisplayConfigurable('form', TRUE);
- $fields['status'] = BaseFieldDefinition::create('boolean')
- ->setLabel(t('Publishing status'))
- ->setDescription(t('A boolean indicating whether the node is published.'))
- ->setRevisionable(TRUE)
- ->setTranslatable(TRUE)
- ->setDefaultValue(TRUE);
-
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Authored on'))
->setDescription(t('The time that the node was created.'))