Hook into node/entity creation/insert 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:

&lt;?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-&gt;field_duplicate_to_news) &amp;&amp; $entity-&gt;field_duplicate_to_news[0] === 'on')
    {
        // create a new news-article here
    }
}


Any help and suggestions are welcome
Whenever in drupal documentation it says to use "hook_" it means to replace "hook_" with the name of your module or theme.  Often on this site, you'll see "mymodule_" used as an example.  When you see "ENTITY_TYPE" in a hook description that is usually going to be "node" "taxonomy_term", "user", etc., it is not the bundle, or subtype of an entity.  Drupal nodes are labelled as "Content Types", which is synonymous with bundle.  Bundle is the term used across many different entities and is a backend term, while they are labelled different things on the front-end for different entity types.  For nodes, they are "Content types", for taxonomy, they are "Vocabularies".

You wouldn't want to use the bundle in your hook if it's looking for "ENTITY_TYPE", so "persbericht" ("press release") isn't correct.  You'd want to use node.

Themes can only implement a small number of hooks, such as alter hooks.  They can't implement CRUD operations.  So you'd want to put this in a custom module.

use Drupal\node\Entity\Node;
/**
 * Implements hook_ENTITY_TYPE_insert().
 */
function mymodule_node_insert(Node $node) {
  if ($node-&gt;bundle() == 'press_release') {
    $copy = Node::create([
      'title' =&gt; $node-&gt;getTitle() . ' copy!',
      'type' =&gt; 'article',
      'status' =&gt; 0,
    ]);
    foreach ($node as $key =&gt; $value) {
      // Copy values from all fields (fields start with "field_").
      if (strpos($key, 'field_') === 0) {
        if (isset($copy-&gt;{$key})) {
          $copy-&gt;{$key}-&gt;setValue($node-&gt;{$key}-&gt;getValue());
        }
      }
    }
    $copy-&gt;save();
  }
}