diff --git a/cern_integration.module b/cern_integration.module index 4fb782dfa092199c996f83c717100f3fe1bc6e98..d3906e0e57004574f511a9861779e76e95e54bcd 100644 --- a/cern_integration.module +++ b/cern_integration.module @@ -1,9 +1,38 @@ <?php +/* Debugging purposes */ //function cern_integration_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { - //drupal_set_message(t("Form ID: $form_id"), "status"); +// drupal_set_message(t("Form ID: $form_id"), "status"); //} +//function cern_integration_form_menu_edit_item_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) { +// drupal_set_message(t("Form ID: $form_id"), "status"); +//} +/* Debugging purposes */ + +/** +* Implements hook_form_FORM_ID_alter() for system_modules_uninstall(). +* Checks whether memcache module exists. If so, disable the possibility of uninstalling it. It's mandatory to have it installed. +*/ +function cern_integration_form_system_modules_uninstall_alter(&$form, &$form_state, $form_id){ + $moduleHandler = \Drupal::service('module_handler'); + if ($moduleHandler->moduleExists('memcache')){ + $form['uninstall']['memcache']['#disabled'] = TRUE; + + global $base_url; + $memcache_setup_link = \Drupal\Core\Link::fromTextAndUrl('Memcache Setup', \Drupal\Core\Url::fromUri("$base_url/_site/memcache.php"))->toString(); + + $txt = '</br>'; + $txt .= '<em>Please, do not uninstall memcache module since it can break down your site.</em>'; + $txt .= '</br>'; + $txt .= "<em>If you do not want to use it, please go to " . $memcache_setup_link . ".</em>"; + + $form['modules']['memcache']['description']['memcache_warning'] = array( + '#markup' => t($txt) + ); + } +} + /** * Implements hook_update_projects_alter(). * Remove Drupal core as well as all centrally managed modules and themes from the Update manager.