function NodeForm::updateStatus
Entity builder updating the node status with the submitted value.
Parameters
string $entity_type_id: The entity type identifier.
\Drupal\node\NodeInterface $node: The node updated with the submitted values.
array $form: The complete form array.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Deprecated
in drupal:8.4.0 and is removed from drupal:9.0.0. The "Publish" button was removed.
See also
File
-
core/
modules/ node/ src/ NodeForm.php, line 229
Class
- NodeForm
- Form handler for the node edit forms.
Namespace
Drupal\nodeCode
public function updateStatus($entity_type_id, NodeInterface $node, array $form, FormStateInterface $form_state) {
$element = $form_state->getTriggeringElement();
if (isset($element['#published_status'])) {
$element['#published_status'] ? $node->setPublished() : $node->setUnpublished();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.