You are here

protected function TrainingForm::buildUserMetric in Opigno statistics 3.x

Same name and namespace in other branches
  1. 8 src/Form/TrainingForm.php \Drupal\opigno_statistics\Form\TrainingForm::buildUserMetric()

Builds one block for the user metrics.

Parameters

string $label: Label.

string $value: Value.

string $help_text: Help text.

Return value

array Render array.

1 call to TrainingForm::buildUserMetric()
TrainingForm::buildUserMetrics in src/Form/TrainingForm.php
Builds user metrics.

File

src/Form/TrainingForm.php, line 191

Class

TrainingForm
Implements the training statistics page.

Namespace

Drupal\opigno_statistics\Form

Code

protected function buildUserMetric($label, $value, $help_text = NULL) {
  return [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'user-metric',
      ],
    ],
    [
      '#type' => 'html_tag',
      '#tag' => 'div',
      '#attributes' => [
        'class' => [
          'user-metric-value',
        ],
      ],
      '#value' => $value,
      $help_text ? [
        '#type' => 'html_tag',
        '#tag' => 'div',
        '#attributes' => [
          'class' => [
            'popover-help',
          ],
          'data-toggle' => 'popover',
          'data-content' => $help_text,
        ],
        '#value' => '?',
      ] : NULL,
    ],
    [
      '#type' => 'html_tag',
      '#tag' => 'div',
      '#attributes' => [
        'class' => [
          'user-metric-label',
        ],
      ],
      '#value' => $label,
    ],
  ];
}