1
0

PhpImagickModule.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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\Theming\SetupChecks;
  8. use OCP\IL10N;
  9. use OCP\IURLGenerator;
  10. use OCP\SetupCheck\ISetupCheck;
  11. use OCP\SetupCheck\SetupResult;
  12. class PhpImagickModule implements ISetupCheck {
  13. public function __construct(
  14. private IL10N $l10n,
  15. private IURLGenerator $urlGenerator,
  16. ) {
  17. }
  18. public function getName(): string {
  19. return $this->l10n->t('PHP Imagick module');
  20. }
  21. public function getCategory(): string {
  22. return 'php';
  23. }
  24. public function run(): SetupResult {
  25. if (!extension_loaded('imagick')) {
  26. return SetupResult::info(
  27. $this->l10n->t('The PHP module "imagick" is not enabled although the theming app is. For favicon generation to work correctly, you need to install and enable this module.'),
  28. $this->urlGenerator->linkToDocs('admin-php-modules')
  29. );
  30. } elseif (count(\Imagick::queryFormats('SVG')) === 0) {
  31. return SetupResult::info(
  32. $this->l10n->t('The PHP module "imagick" in this instance has no SVG support. For better compatibility it is recommended to install it.'),
  33. $this->urlGenerator->linkToDocs('admin-php-modules')
  34. );
  35. } else {
  36. return SetupResult::success();
  37. }
  38. }
  39. }