Skip to content
Snippets Groups Projects
Commit 0958b3c8 authored by Ivan Doroshenko's avatar Ivan Doroshenko
Browse files

Issue #3370656 by Matroskeen: Change notice is not visible on bundle configuration form

parent 20d3dd7f
No related branches found
No related tags found
2 merge requests!68Issue #3298741: Fix the issues reported by phpcs,!59Issue #3370656: Change notice is not visible on bundle configuration form.
......@@ -31,11 +31,17 @@ function rabbit_hole_help($route_name, RouteMatchInterface $route_match) {
*/
function rabbit_hole_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form_mangler = \Drupal::service('rabbit_hole.form_mangler');
$entity_type_manager = \Drupal::service('entity_type.manager');
// Get affected bundle types from enabled entity types.
// @todo Remove this code in 3.0.0 - we should keep only custom redirect here.
$entity_types = \Drupal::config('rabbit_hole.settings')->get('enabled_entity_types');
$affected_bundle_types = array_map(function($entity_type_id) use ($entity_type_manager) {
return $entity_type_manager->getStorage($entity_type_id)->getEntityType()->getBundleEntityType();
}, $entity_types);
$affected_bundle_types = array_filter($affected_bundle_types);
$affected_global_forms = in_array('user', $entity_types, TRUE) ? ['user_admin_settings'] : [];
$affected_bundle_types = \Drupal::service('plugin.manager.rabbit_hole_entity_plugin')
->loadSupportedBundleEntityTypes();
$affected_global_forms = \Drupal::service('plugin.manager.rabbit_hole_entity_plugin')
->loadSupportedGlobalForms();
if ($form_state->getFormObject() instanceof EntityFormInterface) {
$current_type = $form_state->getFormObject()->getEntity()->getEntityTypeId();
$current_operation = $form_state->getFormObject()->getOperation();
......@@ -56,7 +62,7 @@ function rabbit_hole_form_alter(&$form, FormStateInterface $form_state, $form_id
}
}
}
elseif (array_key_exists($form_id, $affected_global_forms)) {
elseif (in_array($form_id, $affected_global_forms, TRUE)) {
$form_mangler->addRabbitHoleChangeNotice($form);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment