You are here

public function EntityPublishedTrait::setPublished in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityPublishedTrait.php \Drupal\Core\Entity\EntityPublishedTrait::setPublished()

File

core/lib/Drupal/Core/Entity/EntityPublishedTrait.php, line 54

Class

EntityPublishedTrait
Provides a trait for published status.

Namespace

Drupal\Core\Entity

Code

public function setPublished($published = NULL) {
  if ($published !== NULL) {
    @trigger_error('The $published parameter is deprecated since version 8.3.x and will be removed in 9.0.0.', E_USER_DEPRECATED);
    $value = (bool) $published;
  }
  else {
    $value = TRUE;
  }
  $key = $this
    ->getEntityType()
    ->getKey('published');
  $this
    ->set($key, $value);
  return $this;
}