-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathContext.php
More file actions
78 lines (68 loc) · 2.08 KB
/
Context.php
File metadata and controls
78 lines (68 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Tables\Db;
use JsonSerializable;
/**
* @method getName(): string
* @method setName(string $value): void
* @method getIcon(): string
* @method setIcon(string $value): void
* @method getDescription(): string
* @method setDescription(string $value): void
* @method getOwnerId(): string
* @method setOwnerId(string $value): void
* @method getOwnerType(): int
* @method setOwnerType(int $value): void
* @method setArchived(bool $value): void
*
* @method getSharing(): array
* @method setSharing(array $value): void
* @method getNodes(): array
* @method setNodes(array $value): void
* @method getPages(): array
* @method setPages(array $value): void
*/
class Context extends EntitySuper implements JsonSerializable {
protected ?string $name = null;
protected ?string $icon = null;
protected ?string $description = null;
protected ?string $ownerId = null;
protected ?int $ownerType = null;
protected bool $archived = false;
// virtual properties
protected ?array $sharing = null;
protected ?array $nodes = null;
protected ?array $pages = null;
protected const VIRTUAL_PROPERTIES = ['sharing', 'nodes', 'pages'];
public function __construct() {
$this->addType('id', 'integer');
$this->addType('owner_type', 'integer');
$this->addType('archived', 'boolean');
}
public function isArchived(): bool {
return $this->archived;
}
public function jsonSerialize(): array {
// basic information
$data = [
'id' => $this->getId(),
'name' => $this->getName(),
'iconName' => $this->getIcon(),
'description' => $this->getDescription(),
'owner' => $this->getOwnerId(),
'ownerType' => $this->getOwnerType(),
'archived' => $this->isArchived(),
];
// extended data
if (is_array($this->sharing) || is_array($this->nodes) || is_array($this->pages)) {
$data['sharing'] = $this->getSharing();
$data['nodes'] = $this->getNodes();
$data['pages'] = $this->getPages();
}
return $data;
}
}