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

128 lines
2.8 KiB
PHP
Raw Normal View History

2020-04-21 20:37:42 +00:00
<?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;
2020-04-21 20:37:42 +00:00
2023-06-16 14:58:23 +00:00
use OCA\Epubreader\Service\PreferenceService;
2020-04-21 20:37:42 +00:00
use OCP\AppFramework\Controller;
2023-06-16 14:58:23 +00:00
use OCP\IRequest;
2020-04-21 20:37:42 +00:00
2023-06-16 14:58:23 +00:00
use OCP\IURLGenerator;
2020-04-21 20:37:42 +00:00
class PreferenceController extends Controller {
2023-06-16 14:58:23 +00:00
private $urlGenerator;
private $preferenceService;
2020-04-21 20:37:42 +00:00
2023-06-16 14:58:23 +00:00
/**
* @param string $AppName
* @param IRequest $request
* @param IURLGenerator $urlGenerator
* @param PreferenceService $preferenceService
*/
public function __construct($AppName,
IRequest $request,
IURLGenerator $urlGenerator,
PreferenceService $preferenceService) {
2020-04-21 20:37:42 +00:00
parent::__construct($AppName, $request);
2023-06-16 14:58:23 +00:00
$this->urlGenerator = $urlGenerator;
$this->preferenceService = $preferenceService;
}
2020-04-21 20:37:42 +00:00
/**
2023-06-16 14:58:23 +00:00
* @brief return preference for $fileId
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $scope
* @param int $fileId
* @param string $name if null, return all preferences for $scope + $fileId
*
2020-04-21 20:37:42 +00:00
* @return array|\OCP\AppFramework\Http\JSONResponse
*/
2023-06-16 14:58:23 +00:00
public function get($scope, $fileId, $name) {
return $this->preferenceService->get($scope, $fileId, $name);
}
2020-04-21 20:37:42 +00:00
/**
2023-06-16 14:58:23 +00:00
* @brief write preference for $fileId
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $scope
* @param int $fileId
* @param string $name
* @param string $value
*
2020-04-21 20:37:42 +00:00
* @return array|\OCP\AppFramework\Http\JSONResponse
*/
2023-06-16 14:58:23 +00:00
public function set($scope, $fileId, $name, $value) {
return $this->preferenceService->set($scope, $fileId, $name, $value);
2020-04-21 20:37:42 +00:00
}
/**
2023-06-16 14:58:23 +00:00
* @brief return default preference
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $scope
* @param string $name if null, return all default preferences for scope
*
2020-04-21 20:37:42 +00:00
* @return array|\OCP\AppFramework\Http\JSONResponse
*/
2023-06-16 14:58:23 +00:00
public function getDefault($scope, $name) {
return $this->preferenceService->getDefault($scope, $name);
}
2020-04-21 20:37:42 +00:00
/**
2023-06-16 14:58:23 +00:00
* @brief write default preference
*
* @NoAdminRequired
* @NoCSRFRequired
*
* @param string $scope
* @param string $name
* @param string $value
*
2020-04-21 20:37:42 +00:00
* @return array|\OCP\AppFramework\Http\JSONResponse
*/
2023-06-16 14:58:23 +00:00
public function setDefault($scope, $name, $value) {
return $this->preferenceService->setDefault($scope, $name, $value);
}
2020-04-21 20:37:42 +00:00
2023-06-16 14:58:23 +00:00
/**
* @brief delete preference
*
* @param string $scope
* @param int $fileId
* @param string $name
*
*/
public function delete($scope, $fileId, $name) {
return $this->preferenceService->delete($scope, $fileId, $name);
}
2020-04-21 20:37:42 +00:00
2023-06-16 14:58:23 +00:00
/**
* @brief delete default preference
*
* @param $scope
* @param $name
*
*/
public function deleteDefault($scope, $name) {
return $this->preferenceService->deleteDefault($scope, $name);
}
2020-04-21 20:37:42 +00:00
}