1
0

RequestTimeController.php 882 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\WorkflowEngine\Controller;
  7. use OCP\AppFramework\Controller;
  8. use OCP\AppFramework\Http\Attribute\NoAdminRequired;
  9. use OCP\AppFramework\Http\JSONResponse;
  10. class RequestTimeController extends Controller {
  11. /**
  12. * @param string $search
  13. * @return JSONResponse
  14. */
  15. #[NoAdminRequired]
  16. public function getTimezones($search = '') {
  17. $timezones = \DateTimeZone::listIdentifiers();
  18. if ($search !== '') {
  19. $timezones = array_filter($timezones, function ($timezone) use ($search) {
  20. return stripos($timezone, $search) !== false;
  21. });
  22. }
  23. $timezones = array_slice($timezones, 0, 10);
  24. $response = [];
  25. foreach ($timezones as $timezone) {
  26. $response[$timezone] = $timezone;
  27. }
  28. return new JSONResponse($response);
  29. }
  30. }