status_messages-8.x-4.2/status_messages.module

status_messages.module
<?php

/**
 * @file
 * This is the module to make simple status messages.
 */

use Drupal\Core\Render\Element\StatusMessages;
use Drupal\Core\Routing\RouteMatchInterface;

/**
 * Implements hook_help().
 */
function status_messages_help($route_name, RouteMatchInterface $route_match) {
  switch ($route_name) {
    case 'help.status_messages':
      $output = '';
      $output .= '<h3>' . t('Status Messages') . '</h3>';
      $output .= '<p>' . t('Status Messages which floats to the top right of the page as a pop-up message
            and has a close button.It has configuration until how much time we want to display the message For eg 
            [5 seconds, 10 seconds, etc].After selected time status message will be faded out and will hide from 
            the display.') . '</p>';
      return $output;
  }
}

/**
 * Implements hook_page_attachments_alter().
 */
function status_messages_page_attachments(array &$attachments) {
  $attachments['#attached']['library'][] = 'status_messages/status-messages';
}

/**
 * Implements hook_theme_registry_alter().
 */
function status_messages_theme_registry_alter(&$theme_registry) {
  $theme_registry['status_messages']['path'] = \Drupal::service('extension.list.module')->getPath('status_messages') . '/templates/misc';
}

/**
 * Implements hook_preprocess().
 */
function status_messages_preprocess(&$variables) {
  $config = \Drupal::config('status_messages.status_messages');
  $variables['status_message_time'] = $config->get('status_message_time');
  $variables['#attached']['drupalSettings']['statusMessages'] = $variables['status_message_time'];
}

/**
 * Implements hook_preprocess_HOOK() for status messages blocks.
 */
function status_messages_preprocess_block__system_messages_block(&$variables) {
  // Adapted from https://www.drupal.org/i/3456176.
  $variables['content'] = StatusMessages::renderMessages();
  $variables['#cache']['max-age'] = 0;
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc