This repository has been archived on 2024-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
epubreader/lib/Controller/PreferenceController.php
Michel Roux 7da83b2595
All checks were successful
epubreader / nextcloud-22 (push) Successful in 1m4s
epubreader / nextcloud-27 (push) Successful in 56s
cleanup (again)
2023-08-02 22:04:03 +02:00

95 lines
2.2 KiB
PHP

<?php
/**
* @author Frank de Lange
* @copyright 2017 Frank de Lange
*
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCA\Epubreader\Controller;
use OCA\Epubreader\Service\PreferenceService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\JSONResponse;
use OCP\IRequest;
class PreferenceController extends Controller
{
private PreferenceService $preferenceService;
public function __construct(
string $AppName,
IRequest $request,
PreferenceService $preferenceService
) {
parent::__construct($AppName, $request);
$this->preferenceService = $preferenceService;
}
/**
* @brief return preference for $fileId
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param ?string $name if null, return all preferences for $scope + $fileId
*/
public function get(string $scope, int $fileId, ?string $name = null): JSONResponse
{
return new JSONResponse($this->preferenceService->get($scope, $fileId, $name));
}
/**
* @brief write preference for $fileId
*
* @NoAdminRequired
* @NoCSRFRequired
*/
public function set(string $scope, int $fileId, string $name, string $value): JSONResponse
{
return new JSONResponse($this->preferenceService->set($scope, $fileId, $name, $value));
}
/**
* @brief return default preference
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $name if null, return all default preferences for scope
*/
public function getDefault(string $scope, string $name): JSONResponse
{
return new JSONResponse($this->preferenceService->getDefault($scope, $name));
}
/**
* @brief write default preference
*
* @NoAdminRequired
* @NoCSRFRequired
*/
public function setDefault(string $scope, string $name, string $value): JSONResponse
{
return new JSONResponse($this->preferenceService->setDefault($scope, $name, $value));
}
/**
* @brief delete preference
*/
public function delete(string $scope, int $fileId, string $name): void
{
$this->preferenceService->delete($scope, $fileId, $name);
}
/**
* @brief delete default preference
*/
public function deleteDefault(string $scope, string $name): void
{
$this->preferenceService->deleteDefault($scope, $name);
}
}