protected function StatisticsPageTrait::buildValueWithIndicator in Opigno statistics 8
Same name and namespace in other branches
- 3.x 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.
3 calls to StatisticsPageTrait::buildValueWithIndicator()
- DashboardForm::buildTrainingsProgress in src/
Form/ DashboardForm.php - Builds trainings progress.
- TrainingForm::buildTrainingsProgress in src/
Form/ TrainingForm.php - Builds training progress.
- UserController::buildTrainingDetails in src/
Controller/ UserController.php - Builds render array for a user training details.
File
- src/
StatisticsPageTrait.php, line 82
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 = isset($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),
];
}