function rabbit_hole_update_8100 in Rabbit Hole 8
Same name and namespace in other branches
- 2.x rabbit_hole.install \rabbit_hole_update_8100()
Install redirect_fallback_action field.
File
- ./
rabbit_hole.install, line 13 - Install, update and uninstall functions for the Rabbit Hole module.
Code
function rabbit_hole_update_8100() {
$rh_definitions = \Drupal::service('plugin.manager.rabbit_hole_entity_plugin')
->getDefinitions();
$update_manager = \Drupal::entityDefinitionUpdateManager();
$rh_redirect_fallback_field = BaseFieldDefinition::create('string')
->setName('rh_redirect_fallback_action')
->setLabel(t('Rabbit Hole redirect fallback action'))
->setDescription(t('Specifies the action that should be used when the redirect path is invalid or empty.'));
foreach ($rh_definitions as $rh_module => $definition) {
$entity_type_id = $definition['entityType'];
$field_storage_definition = $update_manager
->getFieldStorageDefinition('rh_redirect_fallback_action', $entity_type_id);
if (empty($field_storage_definition)) {
$update_manager
->installFieldStorageDefinition('rh_redirect_fallback_action', $entity_type_id, $rh_module, $rh_redirect_fallback_field);
}
}
}