We use the module Rabbit Hole for nodes and terms. Now we would like to use it also for our custom content entities. I have tried to find some information, how to add the Rabbit Hole to a custom content entity. I have found some related information, but maybe there is some manual, which would be more specific.

I have found:

  • 2
    You need to write a plugin of type RabbitHoleEntityPlugin (extending from RabbitHoleEntityPluginBase). There doesn't seem to be any documentation so going through the base class and instances in the submodules (rh_node, rh_taxonomy, rh_user, etc) seems like the best place to start
    – Clive
    Commented Nov 10, 2021 at 16:41
  • 2
    Actually the best docs are probably the method comments in RabbitHoleEntityPluginInterface
    – Clive
    Commented Nov 10, 2021 at 16:44

1 Answer 1


Here is an example for v 1.x.


namespace Drupal\my_module\Plugin\RabbitHoleEntityPlugin;

use Drupal\my_module\Plugin\RabbitHoleEntityPluginBase;

 * Implements rabbit hole behavior for custom eck entity type.
 * @RabbitHoleEntityPlugin(
 *   id = "rh_my_eck_type",
 *   label = @Translation("Custom ECK entity"),
 *   entityType = "custom_eck_entity_type_id"
 * )
class CustomEckEntityType extends RabbitHoleEntityPluginBase {}

Optionally if you want allow override rh rules per each entity then implement this hook:

 * Implements hook_entity_base_field_info().
function my_module_entity_base_field_info(EntityTypeInterface $entity_type) {
  if ($entity_type->id() === 'custom_eck_entity_type_id') {
    $fields = \Drupal::service('rabbit_hole.entity_extender')
    return $fields;

Note: RH v.2.x architecture is different and other content entities should be supported of of the box. v.1 and v.2 are incompatible

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.