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/Db/Preference.php

96 lines
1.9 KiB
PHP
Raw Normal View History

2020-04-21 20:37:42 +00:00
<?php
/**
* @author Frank de Lange
* @copyright 2015 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\Db;
2020-04-21 20:37:42 +00:00
2023-08-02 20:04:03 +00:00
class Preference extends ReaderEntity implements \JsonSerializable
{
2023-06-16 19:20:03 +00:00
protected string $userId; // user for whom this preference is valid
protected string $scope; // scope (default or specific renderer)
protected int $fileId; // file for which this preference is set
protected string $name; // preference name
protected string $value; // preference value
2023-06-16 14:58:23 +00:00
2023-08-02 20:04:03 +00:00
public function jsonSerialize(): array
{
2023-06-16 14:58:23 +00:00
return [
'id' => $this->getId(),
'scope' => $this->getScope(),
'fileId' => $this->getFileId(),
'name' => $this->getName(),
'value' => $this->conditional_json_decode($this->getValue()),
'lastModified' => $this->getLastModified(),
];
}
2023-08-02 20:04:03 +00:00
public function toService(): array
{
2023-06-16 14:58:23 +00:00
return [
'name' => $this->getName(),
'value' => $this->conditional_json_decode($this->getValue()),
];
}
2023-08-02 20:04:03 +00:00
public function getUserId(): string
{
2023-06-16 14:58:23 +00:00
return $this->userId;
}
2023-08-02 20:04:03 +00:00
public function setUserId(string $userId): void
{
2023-06-16 14:58:23 +00:00
$this->userId = $userId;
2023-06-16 23:17:29 +00:00
$this->markFieldUpdated('userId');
2023-06-16 14:58:23 +00:00
}
2023-08-02 20:04:03 +00:00
public function getScope(): string
{
2023-06-16 14:58:23 +00:00
return $this->scope;
}
2023-08-02 20:04:03 +00:00
public function setScope(string $scope): void
{
2023-06-16 14:58:23 +00:00
$this->scope = $scope;
2023-06-16 23:17:29 +00:00
$this->markFieldUpdated('scope');
2023-06-16 14:58:23 +00:00
}
2020-04-21 20:37:42 +00:00
2023-08-02 20:04:03 +00:00
public function getFileId(): int
{
2023-06-16 14:58:23 +00:00
return $this->fileId;
}
2023-08-02 20:04:03 +00:00
public function setFileId(int $fileId): void
{
2023-06-16 14:58:23 +00:00
$this->fileId = $fileId;
2023-06-16 23:17:29 +00:00
$this->markFieldUpdated('fileId');
2023-06-16 14:58:23 +00:00
}
2023-08-02 20:04:03 +00:00
public function getName(): string
{
2023-06-16 14:58:23 +00:00
return $this->name;
}
2023-08-02 20:04:03 +00:00
public function setName(string $name): void
{
2023-06-16 14:58:23 +00:00
$this->name = $name;
2023-06-16 23:17:29 +00:00
$this->markFieldUpdated('name');
2023-06-16 14:58:23 +00:00
}
2023-08-02 20:04:03 +00:00
public function getValue(): string
{
2023-06-16 14:58:23 +00:00
return $this->value;
}
2023-08-02 20:04:03 +00:00
public function setValue(string $value): void
{
2023-06-16 14:58:23 +00:00
$this->value = $value;
2023-06-16 23:17:29 +00:00
$this->markFieldUpdated('value');
2023-06-16 14:58:23 +00:00
}
}