protected function StatisticsPageTrait::buildValueWithIndicator in Opigno statistics 3.x
Same name and namespace in other branches
- 8 src/StatisticsPageTrait.php \Drupal\opigno_statistics\StatisticsPageTrait::buildValueWithIndicator()
Builds value with a indicator for the training progress block.
Parameters
string $label: Value label.
float $value: From 0 to 1.
null|string $value_text: Formatted value (optional).
string $help_text: Help text.
Return value
array Render array.
1 call to StatisticsPageTrait::buildValueWithIndicator()
- UserController::buildTrainingDetails in src/
Controller/ UserController.php - Builds render array for a user training details.
File
- src/
StatisticsPageTrait.php, line 87
Class
- StatisticsPageTrait
- Common helper methods for a statistics pages.
Namespace
Drupal\opigno_statisticsCode
protected function buildValueWithIndicator($label, $value, $value_text = NULL, $help_text = NULL) {
$value_text = $value_text ?? $this
->t('@percent%', [
'@percent' => round(100 * $value),
]);
return [
'#type' => 'container',
'#attributes' => [
'class' => [
'value-indicator-wrapper',
],
],
'value' => $this
->buildValue($label, $value_text, $help_text),
'indicator' => $this
->buildCircleIndicator($value),
];
}