1
0

JSDataService.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Theming\Service;
  8. use OCA\Theming\ThemingDefaults;
  9. use OCA\Theming\Util;
  10. class JSDataService implements \JsonSerializable {
  11. public function __construct(
  12. private ThemingDefaults $themingDefaults,
  13. private Util $util,
  14. private ThemesService $themesService,
  15. ) {
  16. $this->themingDefaults = $themingDefaults;
  17. $this->util = $util;
  18. $this->themesService = $themesService;
  19. }
  20. public function jsonSerialize(): array {
  21. return [
  22. 'name' => $this->themingDefaults->getName(),
  23. 'slogan' => $this->themingDefaults->getSlogan(),
  24. 'url' => $this->themingDefaults->getBaseUrl(),
  25. 'imprintUrl' => $this->themingDefaults->getImprintUrl(),
  26. 'privacyUrl' => $this->themingDefaults->getPrivacyUrl(),
  27. 'primaryColor' => $this->themingDefaults->getColorPrimary(),
  28. 'backgroundColor' => $this->themingDefaults->getColorBackground(),
  29. 'defaultPrimaryColor' => $this->themingDefaults->getDefaultColorPrimary(),
  30. 'defaultBackgroundColor' => $this->themingDefaults->getDefaultColorBackground(),
  31. 'inverted' => $this->util->invertTextColor($this->themingDefaults->getColorPrimary()),
  32. 'cacheBuster' => $this->util->getCacheBuster(),
  33. 'enabledThemes' => $this->themesService->getEnabledThemes(),
  34. // deprecated use primaryColor
  35. 'color' => $this->themingDefaults->getColorPrimary(),
  36. '' => 'color is deprecated since Nextcloud 29, use primaryColor instead'
  37. ];
  38. }
  39. }