2020-06-04 14:31:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2020-08-24 12:54:25 +00:00
|
|
|
|
2020-06-04 14:31:36 +00:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2020, Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
2020-12-16 13:54:15 +00:00
|
|
|
* @author Julien Veyssier <eneiluj@posteo.net>
|
2020-06-04 14:31:36 +00:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2021-06-04 19:52:51 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2020-06-04 14:31:36 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2020-08-24 12:54:25 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2020-06-04 14:31:36 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
namespace OCA\Theming\Service;
|
|
|
|
|
|
|
|
use OCA\Theming\ThemingDefaults;
|
|
|
|
use OCA\Theming\Util;
|
|
|
|
use OCP\IConfig;
|
|
|
|
|
|
|
|
class JSDataService implements \JsonSerializable {
|
2022-04-15 11:54:53 +00:00
|
|
|
private ThemingDefaults $themingDefaults;
|
|
|
|
private Util $util;
|
|
|
|
private IConfig $appConfig;
|
|
|
|
private ThemesService $themesService;
|
2020-06-04 14:31:36 +00:00
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
ThemingDefaults $themingDefaults,
|
|
|
|
Util $util,
|
2022-04-15 11:54:53 +00:00
|
|
|
IConfig $appConfig,
|
|
|
|
ThemesService $themesService
|
2020-06-04 14:31:36 +00:00
|
|
|
) {
|
|
|
|
$this->themingDefaults = $themingDefaults;
|
|
|
|
$this->util = $util;
|
|
|
|
$this->appConfig = $appConfig;
|
2022-04-15 11:54:53 +00:00
|
|
|
$this->themesService = $themesService;
|
2020-06-04 14:31:36 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 15:11:53 +00:00
|
|
|
public function jsonSerialize(): array {
|
2020-06-04 14:31:36 +00:00
|
|
|
return [
|
|
|
|
'name' => $this->themingDefaults->getName(),
|
|
|
|
'url' => $this->themingDefaults->getBaseUrl(),
|
|
|
|
'slogan' => $this->themingDefaults->getSlogan(),
|
|
|
|
'color' => $this->themingDefaults->getColorPrimary(),
|
2022-10-05 09:34:05 +00:00
|
|
|
'defaultColor' => $this->themingDefaults->getDefaultColorPrimary(),
|
2020-06-04 14:31:36 +00:00
|
|
|
'imprintUrl' => $this->themingDefaults->getImprintUrl(),
|
|
|
|
'privacyUrl' => $this->themingDefaults->getPrivacyUrl(),
|
|
|
|
'inverted' => $this->util->invertTextColor($this->themingDefaults->getColorPrimary()),
|
2022-11-15 15:55:37 +00:00
|
|
|
'cacheBuster' => $this->util->getCacheBuster(),
|
2022-04-15 11:54:53 +00:00
|
|
|
'enabledThemes' => $this->themesService->getEnabledThemes(),
|
2020-06-04 14:31:36 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|