Woff2Loading.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Settings\SetupChecks;
  8. use OCP\Http\Client\IClientService;
  9. use OCP\IConfig;
  10. use OCP\IL10N;
  11. use OCP\IURLGenerator;
  12. use OCP\SetupCheck\ISetupCheck;
  13. use OCP\SetupCheck\SetupResult;
  14. use Psr\Log\LoggerInterface;
  15. /**
  16. * Check whether the WOFF2 URLs works
  17. */
  18. class Woff2Loading implements ISetupCheck {
  19. use CheckServerResponseTrait;
  20. public function __construct(
  21. protected IL10N $l10n,
  22. protected IConfig $config,
  23. protected IURLGenerator $urlGenerator,
  24. protected IClientService $clientService,
  25. protected LoggerInterface $logger,
  26. ) {
  27. }
  28. public function getCategory(): string {
  29. return 'network';
  30. }
  31. public function getName(): string {
  32. return $this->l10n->t('WOFF2 file loading');
  33. }
  34. public function run(): SetupResult {
  35. $url = $this->urlGenerator->linkTo('', 'core/fonts/NotoSans-Regular-latin.woff2');
  36. $noResponse = true;
  37. $responses = $this->runHEAD($url);
  38. foreach ($responses as $response) {
  39. $noResponse = false;
  40. if ($response->getStatusCode() === 200) {
  41. return SetupResult::success();
  42. }
  43. }
  44. if ($noResponse) {
  45. return SetupResult::info(
  46. $this->l10n->t('Could not check for WOFF2 loading support. Please check manually if your webserver serves `.woff2` files.') . "\n" . $this->serverConfigHelp(),
  47. $this->urlGenerator->linkToDocs('admin-nginx'),
  48. );
  49. }
  50. return SetupResult::warning(
  51. $this->l10n->t('Your web server is not properly set up to deliver .woff2 files. This is typically an issue with the Nginx configuration. For Nextcloud 15 it needs an adjustement to also deliver .woff2 files. Compare your Nginx configuration to the recommended configuration in our documentation.'),
  52. $this->urlGenerator->linkToDocs('admin-nginx'),
  53. );
  54. }
  55. }