Assigns ownership of a node to a user.
Drupal\node\Node $node: A node entity to modify.
$context: Array of additional information about what triggered the action. Includes the following elements:
node_assign_owner_action_form()
node_assign_owner_action_validate()
node_assign_owner_action_submit()
function node_assign_owner_action(Node $node, $context) {
$node->uid = $context['owner_uid'];
$owner_name = db_query("SELECT name FROM {users} WHERE uid = :uid", array(
':uid' => $context['owner_uid'],
))
->fetchField();
watchdog('action', 'Changed owner of @type %title to uid %name.', array(
'@type' => node_get_type_label($node),
'%title' => $node
->label(),
'%name' => $owner_name,
));
}