|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Uxmp\Core\Orm\Model; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\DBAL\Types\Types; |
|
8
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
9
|
|
|
use Uxmp\Core\Component\Authentication\AccessKey\AccessKeyTypeEnum; |
|
10
|
|
|
use Uxmp\Core\Orm\Repository\AccessKeyRepository; |
|
11
|
|
|
|
|
12
|
|
|
#[ORM\Entity(repositoryClass: AccessKeyRepository::class)] |
|
13
|
|
|
#[ORM\Table(name: 'access_key')] |
|
14
|
|
|
class AccessKey implements AccessKeyInterface |
|
15
|
|
|
{ |
|
16
|
|
|
#[ORM\Column(type: Types::INTEGER)] |
|
17
|
|
|
#[ORM\Id, ORM\GeneratedValue(strategy: 'AUTO')] |
|
18
|
|
|
private int $id; |
|
19
|
|
|
|
|
20
|
|
|
#[ORM\Column(type: Types::INTEGER, enumType: AccessKeyTypeEnum::class)] |
|
21
|
|
|
private AccessKeyTypeEnum $type_id = AccessKeyTypeEnum::NONE; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* @var array{ |
|
|
|
|
|
|
25
|
|
|
* accessKey?: string |
|
26
|
|
|
* } $config |
|
27
|
|
|
*/ |
|
28
|
|
|
#[ORM\Column(type: Types::JSON)] |
|
29
|
|
|
private array $config = []; |
|
30
|
|
|
|
|
31
|
|
|
#[ORM\Column(type: Types::BOOLEAN)] |
|
32
|
|
|
private bool $active = false; |
|
33
|
|
|
|
|
34
|
|
|
#[ORM\Column(type: Types::INTEGER)] |
|
35
|
|
|
private int $user_id = 0; |
|
|
|
|
|
|
36
|
|
|
|
|
37
|
|
|
#[ORM\ManyToOne(targetEntity: UserInterface::class)] |
|
38
|
|
|
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id', nullable: false, onDelete: 'CASCADE')] |
|
39
|
|
|
private UserInterface $user; |
|
40
|
|
|
|
|
41
|
|
|
public function getId(): int |
|
42
|
|
|
{ |
|
43
|
|
|
return $this->id; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
1 |
|
public function getTypeId(): AccessKeyTypeEnum |
|
47
|
|
|
{ |
|
48
|
1 |
|
return $this->type_id; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
1 |
|
public function setTypeId(AccessKeyTypeEnum $typeId): AccessKeyInterface |
|
52
|
|
|
{ |
|
53
|
1 |
|
$this->type_id = $typeId; |
|
54
|
1 |
|
return $this; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
1 |
|
public function getActive(): bool |
|
58
|
|
|
{ |
|
59
|
1 |
|
return $this->active; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
1 |
|
public function setActive(bool $active): AccessKeyInterface |
|
63
|
|
|
{ |
|
64
|
1 |
|
$this->active = $active; |
|
65
|
1 |
|
return $this; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
1 |
|
public function getUser(): UserInterface |
|
69
|
|
|
{ |
|
70
|
1 |
|
return $this->user; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
1 |
|
public function setUser(UserInterface $user): AccessKeyInterface |
|
74
|
|
|
{ |
|
75
|
1 |
|
$this->user = $user; |
|
76
|
1 |
|
return $this; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @return array{ |
|
|
|
|
|
|
81
|
|
|
* accessToken?: string |
|
82
|
|
|
* } |
|
83
|
|
|
*/ |
|
84
|
1 |
|
public function getConfig(): array |
|
85
|
|
|
{ |
|
86
|
1 |
|
return $this->config; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
1 |
|
public function setConfig(array $config): AccessKeyInterface |
|
90
|
|
|
{ |
|
91
|
1 |
|
$this->config = $config; |
|
92
|
1 |
|
return $this; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|