protected function OptionsLimitWebformHandler::getLimitInformation in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_options_limit/src/Plugin/WebformHandler/OptionsLimitWebformHandler.php \Drupal\webform_options_limit\Plugin\WebformHandler\OptionsLimitWebformHandler::getLimitInformation()
Get limit information including label, limit, total, remaining, and status.
Parameters
string $label: The element or option label.
int $limit: The limit.
int $total: The total.
Return value
array The limit information including label, limit, total, remaining, and status.
2 calls to OptionsLimitWebformHandler::getLimitInformation()
- OptionsLimitWebformHandler::getBooleanLimits in modules/
webform_options_limit/ src/ Plugin/ WebformHandler/ OptionsLimitWebformHandler.php - Get an associative array of boolean limits.
- OptionsLimitWebformHandler::getOptionsLimits in modules/
webform_options_limit/ src/ Plugin/ WebformHandler/ OptionsLimitWebformHandler.php - Get an associative array of options limits.
File
- modules/
webform_options_limit/ src/ Plugin/ WebformHandler/ OptionsLimitWebformHandler.php, line 1239
Class
- OptionsLimitWebformHandler
- Webform options and boolean (boolean) limit handler.
Namespace
Drupal\webform_options_limit\Plugin\WebformHandlerCode
protected function getLimitInformation($label, $limit, $total) {
$total = $total ?: 0;
$remaining = $limit ? $limit - $total : 0;
if (empty($limit) && $limit !== 0) {
$status = WebformOptionsLimitHandlerInterface::LIMIT_STATUS_UNLIMITED;
}
elseif ($remaining <= 0) {
$status = WebformOptionsLimitHandlerInterface::LIMIT_STATUS_NONE;
}
elseif ($remaining === 1) {
$status = WebformOptionsLimitHandlerInterface::LIMIT_STATUS_SINGLE;
}
else {
$status = WebformOptionsLimitHandlerInterface::LIMIT_STATUS_MULTIPLE;
}
return [
'label' => $label,
'limit' => $limit,
'total' => $total,
'remaining' => $remaining,
'status' => $status,
];
}