diff --git a/core/lib/Drupal/Core/Entity/EntityPublishedInterface.php b/core/lib/Drupal/Core/Entity/EntityPublishedInterface.php index 03a97ec..77dcb2b 100644 --- a/core/lib/Drupal/Core/Entity/EntityPublishedInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityPublishedInterface.php @@ -18,16 +18,14 @@ public function isPublished(); /** * Sets the entity as published. * - * @return \Drupal\Core\Entity\EntityInterface - * The called entity. + * @return $this */ public function publish(); /** * Sets the entity as unpublished. * - * @return \Drupal\Core\Entity\EntityInterface - * The called entity. + * @return $this */ public function unpublish(); diff --git a/core/lib/Drupal/Core/Entity/EntityPublishedTrait.php b/core/lib/Drupal/Core/Entity/EntityPublishedTrait.php index f8e407d..2e9d4c2 100644 --- a/core/lib/Drupal/Core/Entity/EntityPublishedTrait.php +++ b/core/lib/Drupal/Core/Entity/EntityPublishedTrait.php @@ -11,10 +11,16 @@ trait EntityPublishedTrait { /** - * {@inheritdoc} + * Returns an array of base field definitions for publishing status. + * + * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type + * The entity type to add the publishing status field to. + * + * @return \Drupal\Core\Field\BaseFieldDefinition[] + * Array of base field definitions. */ - public static function publishedBaseFieldDefinitions(EntityTypeInterface $entityType) { - $key = self::getPublishedEntityKey($entityType); + public static function publishedBaseFieldDefinitions(EntityTypeInterface $entity_type) { + $key = static::getPublishedEntityKey($entity_type); return [$key => BaseFieldDefinition::create('boolean') ->setLabel(new TranslatableMarkup('Publishing status')) ->setDescription(new TranslatableMarkup('A boolean indicating the published state.')) @@ -27,7 +33,7 @@ public static function publishedBaseFieldDefinitions(EntityTypeInterface $entity * {@inheritdoc} */ public function isPublished() { - $key = $this->getPublishedEntityKey($this->getEntityType()); + $key = static::getPublishedEntityKey($this->getEntityType()); return (bool) $this->get($key)->value; } @@ -37,8 +43,11 @@ public function isPublished() { * @param bool $published * A boolean value denoting the published status. * - * @return \Drupal\Core\Entity\ContentEntityInterface $this - * The Content Entity object. + * @return $this + * + * @deprecated in Drupal 8.3.0, will be removed before Drupal 9.0.0. Use + * \Drupal\Core\Entity\EntityPublishedInterface::publish() and + * \Drupal\Core\Entity\EntityPublishedInterface::unpublish() instead. */ public function setPublished($published) { if ((bool) $published) { @@ -55,7 +64,7 @@ public function setPublished($published) { * {@inheritdoc} */ public function publish() { - $key = $this->getPublishedEntityKey($this->getEntityType()); + $key = static::getPublishedEntityKey($this->getEntityType()); $this->set($key, TRUE); return $this; @@ -65,7 +74,7 @@ public function publish() { * {@inheritdoc} */ public function unpublish() { - $key = $this->getPublishedEntityKey($this->getEntityType()); + $key = static::getPublishedEntityKey($this->getEntityType()); $this->set($key, FALSE); return $this; @@ -74,16 +83,17 @@ public function unpublish() { /** * Used to determine which key is used to represent the published state. * - * @param \Drupal\Core\Entity\EntityTypeInterface $entityType + * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type to find the published key for. * * @return string * The configured entity type definition key for 'status', or defaults to * 'status'. + * * @see \Drupal\Core\Entity\Annotation\ContentEntityType */ - protected static function getPublishedEntityKey(EntityTypeInterface $entityType) { - return $entityType->getKey('status') ?: 'status'; + protected static function getPublishedEntityKey(EntityTypeInterface $entity_type) { + return $entity_type->getKey('status') ?: 'status'; } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d4963d4..5c86a13 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -14,9 +14,7 @@ use Drupal\Core\Database\Query\AlterableInterface; use Drupal\Core\Database\Query\SelectInterface; use Drupal\Core\Database\StatementInterface; -use Drupal\Core\Entity\ContentEntityBase; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; -use Drupal\Core\Entity\EntityPublishedInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; use Drupal\Core\Routing\RouteMatchInterface;