How do I create and use a custom hook?
This section resides in a controller in the parent module:

$plugin_items = [];
// Call modules that implement the hook, and let them add items.
\Drupal::moduleHandler()-&gt;alter('flot_examples_toc', $plugin_items);
if (count($plugin_items &gt; 0)) {
  $output['plugins'] = [
    '#title' =&gt; 'Plugins',
    '#theme' =&gt; 'item_list',
    '#items' =&gt; $plugin_items,
  ];
}


And this resides in the child [module].module file.

use Drupal\Core\Url;

function mymodule_flot_examples_toc_alter(&amp;$item_list) {
  $options = [
    ':one' =&gt; Url::fromRoute('flot_spider_examples.example')-&gt;toString(),
  ];
  $item_list[] = t('&lt;a href=":one"&gt;Spider Chart&lt;/a&gt; (with spider plugin)', $options);
}


The parent creates an array and passes it to the children by reference. They can alter the array by adding elements to it. The parent then adds it to the render array.