diff --git a/src/Form/UserDiskQuotaSettingsForm.php b/src/Form/UserDiskQuotaSettingsForm.php index bfb443f..2949a27 100644 --- a/src/Form/UserDiskQuotaSettingsForm.php +++ b/src/Form/UserDiskQuotaSettingsForm.php @@ -105,11 +105,11 @@ class UserDiskQuotaSettingsForm extends ConfigFormBase { $config = $this->config('user_disk_quota.settings'); foreach ($form_state->getValue('roles') as $key => $value) { - $value = Bytes::toInt($value); + $value = round(Bytes::toNumber($value)); if ($value == 0) { $value = ''; } - $config->set($key, Bytes::toInt($value)); + $config->set($key, round(Bytes::toNumber($value))); } // If no types are specified quota by type is inactive. diff --git a/user_disk_quota.info.yml b/user_disk_quota.info.yml index 2228c63..d72240e 100644 --- a/user_disk_quota.info.yml +++ b/user_disk_quota.info.yml @@ -2,7 +2,7 @@ name: User Disk Quota type: module description: Defines users disk quota limits on file uploads. core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^8 || ^9 || ^10 package: User dependencies: - drupal:user diff --git a/user_disk_quota.module b/user_disk_quota.module index 2b7049f..82bca46 100644 --- a/user_disk_quota.module +++ b/user_disk_quota.module @@ -37,7 +37,7 @@ function _user_disk_quota_form_quota_validate($element, FormStateInterface $form // Empty means no size restrictions, so don't throw an error. return; } - $max_size = Bytes::toInt($element['#value']); + $max_size = round(Bytes::toNumber($element['#value'])); if (is_null($max_size) || !is_numeric($max_size) || $max_size <= 0) { $err_message = t('The "@field" option must contain a valid value.', ['@field' => FieldFilteredMarkup::create($element['#title'])]); $err_message .= ' ' . t('You can either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).'); @@ -92,7 +92,7 @@ function user_disk_quota_form_user_form_submit($form, FormStateInterface $form_s $account = $form_object->getEntity(); if ($account->id() && $form_state->hasValue(['user_disk_quota_limit'])) { - _user_disk_quota_set_user_quota($account, Bytes::toInt($form_state->getValue('user_disk_quota_limit'))); + _user_disk_quota_set_user_quota($account, round(Bytes::toNumber($form_state->getValue('user_disk_quota_limit')))); } }