function hook_node_prepare

Act on a node object about to be shown on the add/edit form.

This hook is invoked from NodeFormController::prepareEntity() after the type-specific hook_prepare() is invoked.

Parameters

\Drupal\Core\Entity\EntityInterface $node: The node that is about to be shown on the add/edit form.

Related topics

5 functions implement hook_node_prepare()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

book_node_prepare in drupal/core/modules/book/book.module
Implements hook_node_prepare().
comment_node_prepare in drupal/core/modules/comment/comment.module
Implements hook_node_prepare().
datetime_node_prepare in drupal/core/modules/datetime/datetime.module
Implements hook_node_prepare().
menu_node_prepare in drupal/core/modules/menu/menu.module
Implements hook_node_prepare().
translation_node_prepare in drupal/core/modules/translation/translation.module
Implements hook_node_prepare().
1 invocation of hook_node_prepare()
NodeFormController::prepareEntity in drupal/core/modules/node/lib/Drupal/node/NodeFormController.php
Prepares the node object.

File

drupal/core/modules/node/node.api.php, line 627
Hooks provided by the Node module.

Code

function hook_node_prepare(\Drupal\Core\Entity\EntityInterface $node) {
  if (!isset($node->comment)) {
    $node->comment = variable_get("comment_{$node->type}", COMMENT_NODE_OPEN);
  }
}