You are here

public static function FormTrait::createInlineMessage in Markdown 8.2

Creates an inline status message to be used in a render array.

Parameters

array $messages: An array of messages, grouped by message type (i.e. ['status' => ['message']]).

int $weight: The weight of the message.

Return value

array The messages converted into a render array to be used inline.

3 calls to FormTrait::createInlineMessage()
FilterMarkdown::processSubform in src/Plugin/Filter/FilterMarkdown.php
Process callback for constructing markdown settings for this filter.
FootnoteExtension::buildConfigurationForm in src/Plugin/Markdown/CommonMark/Extension/FootnoteExtension.php
Form constructor.
ParserConfigurationForm::buildParserExtensions in src/Form/ParserConfigurationForm.php
Builds the extension settings for a specific parser.

File

src/Traits/FormTrait.php, line 114

Class

FormTrait
Trait providing helpful methods when dealing with forms.

Namespace

Drupal\markdown\Traits

Code

public static function createInlineMessage(array $messages, $weight = -10) {
  static $headings;
  if (!$headings) {
    $headings = [
      'error' => t('Error message'),
      'info' => t('Info message'),
      'status' => t('Status message'),
      'warning' => t('Warning message'),
    ];
  }
  return [
    '#type' => 'item',
    '#weight' => $weight,
    '#theme' => 'status_messages',
    '#message_list' => $messages,
    '#status_headings' => $headings,
  ];
}