Change record status: 
Project: 
Introduced in branch: 
2.0.x
Introduced in version: 
2.0.0-alpha1
Description: 

This change record describes the goals and the list of major changes added in 2.0.0 version.

Initial goals

1. Support all entity types;
2. Create a new page where all entity types and bundles can be managed;
3. For entity overrides, use one "Rabbit Hole" Field API field instead of multiple fields;
4. Remove legacy code to simplify the code and further maintenance;

Credits

The development of Rabbit Hole 2.0 was sponsored and encouraged by EvolvingWeb and DevBranch ❤️

Changes

UI

1. Rabbit Hole bundle settings are not accessible on the bundle configuration form anymore.
Instead, can be accessed via new admin page - Rabbit Hole settings (/admin/config/content/rabbit-hole);
New Rabbit Hole settings page

2. "Rabbit Hole settings" field is now available on "Manage form display" page and can be drag-and-dropped to change the position.

Configuration

1. rabbit_hole.behavior_settings.default_bundle and rabbit_hole.behavior_settings.default config objects were removed;

2. rabbit_hole.settings is a new config with general module settings;

3. In rabbit_hole.behavior_settings.* configs redirect, redirect_code, redirect_fallback_action properties were moved under configuration array, which exists for plugin-specific settings.

Before:

id: user
entity_type_id: user
entity_id: null
action: page_redirect
redirect: '[user:edit-url]'
redirect_code: 301
redirect_fallback_action: access_denied

After:

id: user
entity_type_id: user
entity_id: null
action: page_redirect
configuration:
    redirect: '[user:edit-url]'
    redirect_code: 301
    redirect_fallback_action: access_denied

4. allow_override property was removed from rabbit_hole.behavior_settings.* configuration objects. The existence of "Rabbit Hole" is used to define whether overrides for individual entities are allowed.

5. More config changes described here: https://www.drupal.org/node/3374669

Fields

Base fields (rh_action, rh_redirect, rh_redirect_response, rh_redirect_fallback_action) were replaced with a single "Rabbit Hole settings" field (rabbit_hole__settings).

"Rabbit Hole settings" is a field of "Rabbit Hole" type and consists of 2 properties: action and settings. Action-related configuration is stored in settings property. The list of changes:

Before After
rh_action rabbit_hole__settings.action
rh_redirect rabbit_hole__settings.settings.redirect
rh_redirect_response rabbit_hole__settings.settings.redirect_code (changed to be aligned with configuration property)
rh_redirect_fallback_action rabbit_hole__settings.settings.redirect_fallback_action

"Rabbit Hole settings" field is locked, so it cannot be added/removed on "Manage Fields" page. The field is created or removed based on the submitted values on "Rabbit Hole" settings page of entity type.

Get field values

Before After
$entity->get('rh_action')->value;
$entity->get('rh_redirect')->value;
$entity->get('rh_redirect_response')->value;
$entity->get('rh_redirect_fallback_action')->value;
$entity->get('rabbit_hole__settings')->action;
$entity->get('rabbit_hole__settings')->settings['redirect'];
$entity->get('rabbit_hole__settings')->settings['redirect_code'];
$entity->get('rabbit_hole__settings')->settings['redirect_fallback_action'];

Set field values

Before After
$entity->set('rh_action', 'page_redirect');
$entity->set('rh_redirect', 'https://savelife.in.ua/en/');
$entity->set('rh_redirect_response', 307);
$entity->set('rh_redirect_fallback_action', 'access_denied');
$entity->set('rabbit_hole__settings', [
  'action' => 'page_redirect',
  'settings' => [
    'redirect' => 'https://savelife.in.ua/en/',
    'redirect_code' => 307,
    'redirect_fallback_action' => 'access_denied',
  ],
]);

Other changes

1. Implementations of hook_rabbit_hole_values_alter() hook should access values without rh_ prefix. Prefixed values still exist in the array, but they are deprecated and will be removed in the next major version.

2. All sub-modules were deprecated and will be removed in the next major version.

Impacts: 
Site builders, administrators, editors
Module developers
Site templates, recipes and distribution developers