You are here

public function PrivateMessageThreadMessageFormatter::settingsForm in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/PrivateMessageThreadMessageFormatter.php \Drupal\private_message\Plugin\Field\FieldFormatter\PrivateMessageThreadMessageFormatter::settingsForm()

Returns a form to configure settings for the formatter.

Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.

Parameters

array $form: The form where the settings form is being included in.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form elements for the formatter settings.

Overrides FormatterBase::settingsForm

File

src/Plugin/Field/FieldFormatter/PrivateMessageThreadMessageFormatter.php, line 161

Class

PrivateMessageThreadMessageFormatter
Defines the private message thread message field formatter.

Namespace

Drupal\private_message\Plugin\Field\FieldFormatter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element['message_count'] = [
    '#title' => $this
      ->t('Message Count'),
    '#type' => 'number',
    '#default_value' => $this
      ->getSetting('message_count'),
    '#description' => $this
      ->t('The number of messages to display on load'),
  ];
  $element['ajax_previous_load_count'] = [
    '#title' => $this
      ->t('Load Previous Ajax Count'),
    '#type' => 'number',
    '#default_value' => $this
      ->getSetting('ajax_previous_load_count'),
    '#description' => $this
      ->t('The number of previous messages to load using ajax when clicking the load previous link'),
  ];
  $element['ajax_refresh_rate'] = [
    '#title' => $this
      ->t('Ajax refresh rate'),
    '#type' => 'number',
    '#default_value' => $this
      ->getSetting('ajax_refresh_rate'),
    '#description' => $this
      ->t('The number of seconds between checks for new messages. Set to zero to disable. Note that a lower number will cause more requests, use more bandwidth, and cause more strain on the server. As such, it is not recommended to set a value lower than five (5) seconds.'),
  ];
  $element['message_order'] = [
    '#type' => 'radios',
    '#title' => $this
      ->t('Message direction'),
    '#options' => [
      'asc' => $this
        ->translateKey('order', 'asc'),
      'desc' => $this
        ->translateKey('order', 'desc'),
    ],
    '#description' => $this
      ->t('Whether to show messages first to last, or last to first'),
    '#default_value' => $this
      ->getSetting('message_order'),
  ];
  return $element;
}