You are here

function save_edit_form_submit_presave in Save & Edit 8

The published status needs to be altered before the node is saved.

1 string reference to 'save_edit_form_submit_presave'
save_edit_form_alter in ./save_edit.module
Implements hook_form_alter().

File

./save_edit.module, line 79
Contains save_edit.module..

Code

function save_edit_form_submit_presave(&$form, FormStateInterface $form_state) {
  $config = \Drupal::config('save_edit.settings');
  $entity = $form_state
    ->getFormObject()
    ->getEntity();
  if ($config
    ->get('unpublish') || $config
    ->get('unpublish_new_only') && $entity
    ->isNew()) {
    $entity
      ->setPublished(FALSE);
  }
}