Same name and namespace in other branches
  1. 8.9.x core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node::setSticky()
  2. 9 core/modules/node/src/Entity/Node.php \Drupal\node\Entity\Node::setSticky()

Sets the node sticky status.

Parameters

bool $sticky: TRUE to set this node to sticky, FALSE to set it to not sticky.

Return value

$this The called node entity.

Overrides NodeInterface::setSticky

File

core/modules/node/src/Entity/Node.php, line 254

Class

Node
Defines the node entity class.

Namespace

Drupal\node\Entity

Code

public function setSticky($sticky) {
  $this
    ->set('sticky', $sticky ? NodeInterface::STICKY : NodeInterface::NOT_STICKY);
  return $this;
}