Functionally, what I want to achieve is to duplicate a node (with a different node-type) when creating/inserting.
To be more precise: I have two content types: news and press-release. What I want to achieve is that when a press-release is made in admin, a news item is automatically created as well.
I looked into D8 hooks (hook_ENTITY_TYPE_insert to be specific), but can't get it to work, the documentation is confusing to me. This is what my .theme file looks like:
<?php
/**
* @file
* Bootstrap sub-theme.
*
* Place your custom PHP code in this file.
*/
/*
* Implements hook_ENTITY_TYPE_insert().
*/
function hook_persbericht_insert(Drupal\Core\Entity\EntityInterface $entity)
{
if (isset($entity->field_duplicate_to_news) && $entity->field_duplicate_to_news[0] === 'on')
{
// create a new news-article here
}
}
Any help and suggestions are welcome