-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFieldDefinition.php
More file actions
90 lines (82 loc) · 2.47 KB
/
FieldDefinition.php
File metadata and controls
90 lines (82 loc) · 2.47 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
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* SPDX-FileCopyrightText: 2026 LibreCode coop and LibreCode contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
namespace OCA\ProfileFields\Db;
use OCP\AppFramework\Db\Entity;
/**
* @method int getId()
* @method void setId(int $value)
* @method string getFieldKey()
* @method void setFieldKey(string $value)
* @method string getLabel()
* @method void setLabel(string $value)
* @method string getType()
* @method void setType(string $value)
* @method string getEditPolicy()
* @method void setEditPolicy(string $value)
* @method string getExposurePolicy()
* @method void setExposurePolicy(string $value)
* @method int getSortOrder()
* @method void setSortOrder(int $value)
* @method bool getActive()
* @method void setActive(bool $value)
* @method string|null getOptions()
* @method void setOptions(?string $value)
* @method \DateTimeInterface getCreatedAt()
* @method void setCreatedAt(\DateTimeInterface $value)
* @method \DateTimeInterface getUpdatedAt()
* @method void setUpdatedAt(\DateTimeInterface $value)
*/
class FieldDefinition extends Entity {
protected $fieldKey;
protected $label;
protected $type;
protected $editPolicy;
protected $exposurePolicy;
protected $sortOrder;
protected $active;
protected $options;
protected $createdAt;
protected $updatedAt;
public function __construct() {
$this->addType('id', 'integer');
$this->addType('sortOrder', 'integer');
$this->addType('active', 'boolean');
$this->addType('createdAt', 'datetime');
$this->addType('updatedAt', 'datetime');
}
/**
* @return array{
* id: int,
* field_key: string,
* label: string,
* type: string,
* edit_policy: string,
* exposure_policy: string,
* sort_order: int,
* active: bool,
* options: list<string>|null,
* created_at: string,
* updated_at: string,
* }
*/
public function jsonSerialize(): array {
$rawOptions = $this->getOptions();
return [
'id' => $this->getId(),
'field_key' => $this->getFieldKey(),
'label' => $this->getLabel(),
'type' => $this->getType(),
'edit_policy' => $this->getEditPolicy(),
'exposure_policy' => $this->getExposurePolicy(),
'sort_order' => $this->getSortOrder(),
'active' => $this->getActive(),
'options' => $rawOptions !== null ? (json_decode($rawOptions, true) ?? null) : null,
'created_at' => $this->getCreatedAt()->format(DATE_ATOM),
'updated_at' => $this->getUpdatedAt()->format(DATE_ATOM),
];
}
}