1
0

DefaultPhoneRegionSet.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\SetupChecks;
  8. use OCP\IConfig;
  9. use OCP\IL10N;
  10. use OCP\SetupCheck\ISetupCheck;
  11. use OCP\SetupCheck\SetupResult;
  12. class DefaultPhoneRegionSet implements ISetupCheck {
  13. public function __construct(
  14. private IL10N $l10n,
  15. private IConfig $config,
  16. ) {
  17. }
  18. public function getName(): string {
  19. return $this->l10n->t('Default phone region');
  20. }
  21. public function getCategory(): string {
  22. return 'config';
  23. }
  24. public function run(): SetupResult {
  25. if ($this->config->getSystemValueString('default_phone_region', '') !== '') {
  26. return SetupResult::success($this->config->getSystemValueString('default_phone_region', ''));
  27. } else {
  28. return SetupResult::info(
  29. $this->l10n->t('Your installation has no default phone region set. This is required to validate phone numbers in the profile settings without a country code. To allow numbers without a country code, please add "default_phone_region" with the respective ISO 3166-1 code of the region to your config file.'),
  30. 'https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements'
  31. );
  32. }
  33. }
  34. }