Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Analyzer.php

function Analyzer::formatMessage

Formats an analysis message.

This tool should be called by any module responding to the analyze hook to properly format the message. It is usually used in the form:

$ret[] = Analyzer::formatMessage(t('This is the message'), 'ok');

The 'ok' status should be used to provide information about things that are acceptable. In general analysis isn't interested in 'ok' messages, but instead the 'warning', which is a category for items that may be broken unless the user knows what they are doing, and 'error' for items that are definitely broken are much more useful.

Parameters

string $message: The message.

string $type: The type of message. This should be "ok", "warning" or "error". Other values can be used but how they are treated by the output routine is undefined.

Return value

array A single formatted message, consisting of a key message and a key type.

4 calls to Analyzer::formatMessage()
Analyzer::formatMessages in core/modules/views/src/Analyzer.php
Formats the analyze result into a message string.
hook_views_analyze in core/modules/views/views.api.php
Analyze a view to provide warnings about its configuration.
NodeViewsHooks::viewsAnalyze in core/modules/node/src/Hook/NodeViewsHooks.php
Implements hook_views_analyze().
ViewsUiHooks::viewsAnalyze in core/modules/views_ui/src/Hook/ViewsUiHooks.php
Implements hook_views_analyze().

File

core/modules/views/src/Analyzer.php, line 121

Class

Analyzer
View analyzer plugin manager.

Namespace

Drupal\views

Code

public static function formatMessage($message, $type = 'error') {
    return [
        'message' => $message,
        'type' => $type,
    ];
}
RSS feed
Powered by Drupal