function disable_messages_preprocess_status_messages in Disable Messages 8
Same name and namespace in other branches
- 2.x disable_messages.module \disable_messages_preprocess_status_messages()
Implements hook_preprocess_HOOK().
File
- ./
disable_messages.module, line 49 - The disable_messages module file.
Code
function disable_messages_preprocess_status_messages(&$variables) {
$uid = \Drupal::currentUser()
->id();
$filter_message = \Drupal::config('disable_messages.settings')
->get('disable_messages_ignore_patterns');
if (!\Drupal::config('disable_messages.settings')
->get('disable_messages_enable') || $uid == 1 || !$filter_message) {
if ($uid == 1 || !$filter_message) {
$cache = $variables['message_list'];
$cache['excluded']['page'] = FALSE;
$cache['excluded']['uid'] = FALSE;
Drupal::cache()
->set('cache_messages', $cache);
}
// Retrieve messages.
$messages = $variables['message_list'];
}
else {
// Retrieve messages.
$messages = $variables['message_list'];
// Filter messages if filtering is enabled.
$message_list = disable_messages_apply_filters($messages);
$variables['message_list'] = $message_list;
}
}