|
10 | 10 | namespace OCA\AppAPI\Db; |
11 | 11 |
|
12 | 12 | use JsonSerializable; |
13 | | -use OCP\AppFramework\Db\Entity; |
14 | 13 |
|
15 | 14 | /** |
16 | | - * Class ExAppPreference |
| 15 | + * App per-user preference value object. |
17 | 16 | * |
18 | | - * @package OCA\AppAPI\Db |
| 17 | + * Historically a database entity backed by the `preferences_ex` table. ExApp preferences now |
| 18 | + * live in the server's standard `oc_preferences` (via {@see \OCA\AppAPI\Service\ExAppPreferenceService}); |
| 19 | + * this class remains as a plain serializable DTO for OCS responses and internal callers. |
19 | 20 | * |
20 | | - * @method string getUserid() |
21 | | - * @method string getAppid() |
22 | | - * @method string getConfigkey() |
23 | | - * @method string getConfigvalue() |
24 | | - * @method int getSensitive() |
25 | | - * @method void setUserid(string $userid) |
26 | | - * @method void setAppid(string $appid) |
27 | | - * @method void setConfigkey(string $configkey) |
28 | | - * @method void setConfigvalue(string $configvalue) |
29 | | - * @method void setSensitive(int $sensitive) |
| 21 | + * The `id` field has no surrogate key anymore (the server table uses a composite primary key); |
| 22 | + * it is kept in the serialized shape as `0` for backwards compatibility and is unused. |
30 | 23 | */ |
31 | | -class ExAppPreference extends Entity implements JsonSerializable { |
32 | | - protected $userid; |
33 | | - protected $appid; |
34 | | - protected $configkey; |
35 | | - protected $configvalue; |
36 | | - protected $sensitive; |
| 24 | +class ExAppPreference implements JsonSerializable { |
| 25 | + private int $id; |
| 26 | + private string $userid; |
| 27 | + private string $appid; |
| 28 | + private string $configkey; |
| 29 | + private string $configvalue; |
| 30 | + private int $sensitive; |
37 | 31 |
|
38 | | - /** |
39 | | - * @param array $params |
40 | | - */ |
41 | 32 | public function __construct(array $params = []) { |
42 | | - $this->addType('userid', 'string'); |
43 | | - $this->addType('appid', 'string'); |
44 | | - $this->addType('configkey', 'string'); |
45 | | - $this->addType('configvalue', 'string'); |
46 | | - $this->addType('sensitive', 'integer'); |
| 33 | + $this->id = isset($params['id']) ? (int)$params['id'] : 0; |
| 34 | + $this->userid = (string)($params['userid'] ?? ''); |
| 35 | + $this->appid = (string)($params['appid'] ?? ''); |
| 36 | + $this->configkey = (string)($params['configkey'] ?? ''); |
| 37 | + $this->configvalue = (string)($params['configvalue'] ?? ''); |
| 38 | + $this->sensitive = (int)($params['sensitive'] ?? 0); |
| 39 | + } |
| 40 | + |
| 41 | + public function getId(): int { |
| 42 | + return $this->id; |
| 43 | + } |
| 44 | + |
| 45 | + public function getUserid(): string { |
| 46 | + return $this->userid; |
| 47 | + } |
| 48 | + |
| 49 | + public function getAppid(): string { |
| 50 | + return $this->appid; |
| 51 | + } |
| 52 | + |
| 53 | + public function getConfigkey(): string { |
| 54 | + return $this->configkey; |
| 55 | + } |
| 56 | + |
| 57 | + public function getConfigvalue(): string { |
| 58 | + return $this->configvalue; |
| 59 | + } |
| 60 | + |
| 61 | + public function setConfigvalue(string $configValue): void { |
| 62 | + $this->configvalue = $configValue; |
| 63 | + } |
| 64 | + |
| 65 | + public function getSensitive(): int { |
| 66 | + return $this->sensitive; |
| 67 | + } |
47 | 68 |
|
48 | | - if (isset($params['id'])) { |
49 | | - $this->setId($params['id']); |
50 | | - } |
51 | | - if (isset($params['userid'])) { |
52 | | - $this->setUserid($params['userid']); |
53 | | - } |
54 | | - if (isset($params['appid'])) { |
55 | | - $this->setAppid($params['appid']); |
56 | | - } |
57 | | - if (isset($params['configkey'])) { |
58 | | - $this->setConfigkey($params['configkey']); |
59 | | - } |
60 | | - if (isset($params['configvalue'])) { |
61 | | - $this->setConfigvalue($params['configvalue']); |
62 | | - } |
63 | | - if (isset($params['sensitive'])) { |
64 | | - $this->setSensitive($params['sensitive']); |
65 | | - } |
| 69 | + public function setSensitive(int $sensitive): void { |
| 70 | + $this->sensitive = $sensitive; |
66 | 71 | } |
67 | 72 |
|
68 | 73 | public function jsonSerialize(): array { |
69 | 74 | return [ |
70 | | - 'id' => $this->getId(), |
71 | | - 'user_id' => $this->getUserid(), |
72 | | - 'appid' => $this->getAppid(), |
73 | | - 'configkey' => $this->getConfigkey(), |
74 | | - 'configvalue' => $this->getConfigvalue(), |
75 | | - 'sensitive' => $this->getSensitive(), |
| 75 | + 'id' => $this->id, |
| 76 | + 'user_id' => $this->userid, |
| 77 | + 'appid' => $this->appid, |
| 78 | + 'configkey' => $this->configkey, |
| 79 | + 'configvalue' => $this->configvalue, |
| 80 | + 'sensitive' => $this->sensitive, |
76 | 81 | ]; |
77 | 82 | } |
78 | 83 | } |
0 commit comments