Prepares the node object.
Fills in a few default values, and then invokes hook_prepare() on the node type module, and hook_node_prepare() on all modules.
Overrides Drupal\Core\Entity\EntityFormController::prepareEntity().
Overrides EntityFormController::prepareEntity
protected function prepareEntity(EntityInterface $node) {
// Set up default values, if required.
$node_options = variable_get('node_options_' . $node->type, array(
'status',
'promote',
));
// If this is a new node, fill in the default values.
if (!isset($node->nid) || isset($node->is_new)) {
foreach (array(
'status',
'promote',
'sticky',
) as $key) {
// Multistep node forms might have filled in something already.
if (!isset($node->{$key})) {
$node->{$key} = (int) in_array($key, $node_options);
}
}
global $user;
$node->uid = $user->uid;
$node->created = REQUEST_TIME;
}
else {
$node->date = format_date($node->created, 'custom', 'Y-m-d H:i:s O');
// Remove the log message from the original node entity.
$node->log = NULL;
}
// Always use the default revision setting.
$node
->setNewRevision(in_array('revision', $node_options));
node_invoke($node, 'prepare');
module_invoke_all('node_prepare', $node);
}