You are here

public function Event::setPublished in Event 8

Sets the entity as published.

Parameters

bool|null $published: (optional and deprecated) TRUE to set this entity to published, FALSE to set it to unpublished. Defaults to NULL. This parameter is deprecated in Drupal 8.3.0 and will be removed before Drupal 9.0.0. Use this method, without any parameter, to set the entity as published and setUnpublished() to set the entity as unpublished.

Return value

$this

Overrides EntityPublishedInterface::setPublished

See also

\Drupal\Core\Entity\EntityPublishedInterface::setUnpublished()

File

src/Entity/Event.php, line 218

Class

Event
Defines the Event entity.

Namespace

Drupal\event\Entity

Code

public function setPublished($published = NULL) {
  $this
    ->set('status', $published ? TRUE : FALSE);
  return $this;
}