2020-06-04 10:31:36 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2020-08-24 08:54:25 -04:00
|
|
|
|
2020-06-04 10:31:36 -04:00
|
|
|
/**
|
2024-05-30 14:13:41 -04:00
|
|
|
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2020-06-04 10:31:36 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Theming\Service;
|
|
|
|
|
|
|
|
|
|
use OCA\Theming\ThemingDefaults;
|
|
|
|
|
use OCA\Theming\Util;
|
|
|
|
|
|
|
|
|
|
class JSDataService implements \JsonSerializable {
|
|
|
|
|
|
|
|
|
|
public function __construct(
|
2024-01-19 19:56:18 -05:00
|
|
|
private ThemingDefaults $themingDefaults,
|
|
|
|
|
private Util $util,
|
|
|
|
|
private ThemesService $themesService,
|
2020-06-04 10:31:36 -04:00
|
|
|
) {
|
|
|
|
|
$this->themingDefaults = $themingDefaults;
|
|
|
|
|
$this->util = $util;
|
2022-04-15 07:54:53 -04:00
|
|
|
$this->themesService = $themesService;
|
2020-06-04 10:31:36 -04:00
|
|
|
}
|
|
|
|
|
|
2021-10-19 11:11:53 -04:00
|
|
|
public function jsonSerialize(): array {
|
2020-06-04 10:31:36 -04:00
|
|
|
return [
|
|
|
|
|
'name' => $this->themingDefaults->getName(),
|
|
|
|
|
'slogan' => $this->themingDefaults->getSlogan(),
|
2024-02-16 09:25:04 -05:00
|
|
|
|
|
|
|
|
'url' => $this->themingDefaults->getBaseUrl(),
|
2020-06-04 10:31:36 -04:00
|
|
|
'imprintUrl' => $this->themingDefaults->getImprintUrl(),
|
|
|
|
|
'privacyUrl' => $this->themingDefaults->getPrivacyUrl(),
|
2024-02-16 09:25:04 -05:00
|
|
|
|
|
|
|
|
'primaryColor' => $this->themingDefaults->getColorPrimary(),
|
|
|
|
|
'backgroundColor' => $this->themingDefaults->getColorBackground(),
|
|
|
|
|
'defaultPrimaryColor' => $this->themingDefaults->getDefaultColorPrimary(),
|
|
|
|
|
'defaultBackgroundColor' => $this->themingDefaults->getDefaultColorBackground(),
|
2020-06-04 10:31:36 -04:00
|
|
|
'inverted' => $this->util->invertTextColor($this->themingDefaults->getColorPrimary()),
|
2024-02-16 09:25:04 -05:00
|
|
|
|
2022-11-15 10:55:37 -05:00
|
|
|
'cacheBuster' => $this->util->getCacheBuster(),
|
2022-04-15 07:54:53 -04:00
|
|
|
'enabledThemes' => $this->themesService->getEnabledThemes(),
|
2024-02-16 09:25:04 -05:00
|
|
|
|
|
|
|
|
// deprecated use primaryColor
|
|
|
|
|
'color' => $this->themingDefaults->getColorPrimary(),
|
2024-01-19 19:56:18 -05:00
|
|
|
'' => 'color is deprecated since Nextcloud 29, use primaryColor instead'
|
2020-06-04 10:31:36 -04:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|