Skip to content
Snippets Groups Projects
Commit ddff1b3c authored by catch's avatar catch
Browse files

Issue #2218691 by dawehner: Move the current user out of the node API chain in book.

parent 0cb6fc70
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -224,8 +224,13 @@ function book_form_node_form_alter(&$form, &$form_state, $form_id) { ...@@ -224,8 +224,13 @@ function book_form_node_form_alter(&$form, &$form_state, $form_id) {
* *
* @todo: Remove this in favor of an entity field. * @todo: Remove this in favor of an entity field.
*/ */
function book_node_builder($entity_type, $entity, &$form, &$form_state) { function book_node_builder($entity_type, NodeInterface $entity, &$form, &$form_state) {
$entity->book = $form_state['values']['book']; $entity->book = $form_state['values']['book'];
// Always save a revision for non-administrators.
if (!empty($entity->book['bid']) && !\Drupal::currentUser()->hasPermission('administer nodes')) {
$entity->setNewRevision();
}
} }
/** /**
...@@ -447,10 +452,6 @@ function book_node_view(EntityInterface $node, EntityViewDisplayInterface $displ ...@@ -447,10 +452,6 @@ function book_node_view(EntityInterface $node, EntityViewDisplayInterface $displ
* Implements hook_node_presave(). * Implements hook_node_presave().
*/ */
function book_node_presave(EntityInterface $node) { function book_node_presave(EntityInterface $node) {
// Always save a revision for non-administrators.
if (!empty($node->book['bid']) && !\Drupal::currentUser()->hasPermission('administer nodes')) {
$node->setNewRevision();
}
// Make sure a new node gets a new menu link. // Make sure a new node gets a new menu link.
if ($node->isNew()) { if ($node->isNew()) {
$node->book['nid'] = NULL; $node->book['nid'] = NULL;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment