1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kalanis\kw_auth\Sources\Mapper\Database; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use kalanis\kw_auth\Interfaces\IGroup; |
7
|
|
|
use kalanis\kw_auth\Traits\TSeparated; |
8
|
|
|
use kalanis\kw_mapper\Interfaces\IEntryType; |
9
|
|
|
use kalanis\kw_mapper\Records\ASimpleRecord; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class GroupsRecord |
14
|
|
|
* @package kalanis\kw_auth\Sources\Mapper\Database |
15
|
|
|
* @property string $id |
16
|
|
|
* @property string $name |
17
|
|
|
* @property string $desc |
18
|
|
|
* @property string $authorId |
19
|
|
|
* @property string $parents |
20
|
|
|
* @property int $status |
21
|
|
|
* @property UsersRecord[] $authors |
22
|
|
|
* @property UsersRecord[] $members |
23
|
|
|
* @codeCoverageIgnore remote source |
24
|
|
|
*/ |
25
|
|
|
class GroupsRecord extends ASimpleRecord implements IGroup |
26
|
|
|
{ |
27
|
|
|
use TSeparated; |
28
|
|
|
|
29
|
|
|
public function addEntries(): void |
30
|
|
|
{ |
31
|
|
|
$this->addEntry('id', IEntryType::TYPE_STRING, 2048); |
32
|
|
|
$this->addEntry('name', IEntryType::TYPE_STRING, 512); |
33
|
|
|
$this->addEntry('desc', IEntryType::TYPE_STRING, 512); |
34
|
|
|
$this->addEntry('authorId', IEntryType::TYPE_STRING, 128); |
35
|
|
|
$this->addEntry('parents', IEntryType::TYPE_STRING, 2048); |
36
|
|
|
$this->addEntry('status', IEntryType::TYPE_INTEGER, 4); |
37
|
|
|
$this->addEntry('authors', IEntryType::TYPE_ARRAY, []); |
38
|
|
|
$this->addEntry('members', IEntryType::TYPE_ARRAY, []); |
39
|
|
|
$this->setMapper(GroupsMapper::class); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function setGroupData(?string $id, ?string $name, ?string $desc, ?string $authorId, ?int $status, ?array $parents = []): void |
43
|
|
|
{ |
44
|
|
|
$this->id = $id ?? $this->id; |
45
|
|
|
$this->name = $name ?? $this->name; |
46
|
|
|
$this->desc = $desc ?? $this->desc; |
47
|
|
|
$this->authorId = $authorId ?? $this->authorId; |
48
|
|
|
$this->status = $status ?? $this->status; |
49
|
|
|
$this->parents = $parents ? $this->compactStr($parents) : $this->parents; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function getGroupId(): string |
53
|
|
|
{ |
54
|
|
|
return strval($this->id); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getGroupName(): string |
58
|
|
|
{ |
59
|
|
|
return strval($this->name); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getGroupDesc(): string |
63
|
|
|
{ |
64
|
|
|
return strval($this->desc); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function getGroupAuthorId(): string |
68
|
|
|
{ |
69
|
|
|
return strval($this->authorId); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function getGroupStatus(): int |
73
|
|
|
{ |
74
|
|
|
return intval($this->status); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function getGroupParents(): array |
78
|
|
|
{ |
79
|
|
|
return $this->separateStr($this->parents); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|