Does Drupal 8 do that yet?
Not that I know of.
How would you effectively do this?
I would use hook_ENTITY_TYPE_presave and sprinkle some custom code, like the following simple example:
function MODULE_node_presave(Drupal\node\NodeInterface $node) {
if ($node->bundle() == 'article') {
$node2 = Node::load($node->field_reference->value); // load referenced node.
$node2->field_reference->value = $node->id(); // reference back original node.
$node2->save(); // save referenced node.
}
}
}
If they are different content types the above is fine.
If they are the same content type, then watch out for infinite loop!
Add a condition to check if the reference already exists, or save directly to DB to prevent another presave hook from firing.
I believe when you delete node, Drupal automatically deletes references, but double check on that by looking at the DB.
You will also want to cover the scenario when a reference gets removed via node update, to do that use:
function MODULE_node_presave(Drupal\node\NodeInterface $node) {
if ($node->bundle() == 'article') {
if (!empty($node->original) &&
$node->original->field_reference->value != $node->field_reference->value) { // check if it changed
$node2 = Node::load($node->original->field_reference->value); // load removed referenced node.
$node2->field_reference->value = ''; // remove reference back to original node.
$node2->save(); // save removed referenced node.
}
}
}
Obviously all the above is the most basic scenario, if you allow for multiple values, you'll have to work with loops and arrays and perhaps with even with the Batch API if there are lots of nodes that reference the same node.
That said, the above is only necessary in special use cases, where the owner wants to be able to link or unlink from either end. Most of the time one way is enough, as you can easily get the referencing node info via views relationship, twig, or DB query.