|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Spiral Framework. |
|
4
|
|
|
* |
|
5
|
|
|
* @license MIT |
|
6
|
|
|
* @author Anton Titov (Wolfy-J) |
|
7
|
|
|
*/ |
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Cycle\Annotated\Annotation; |
|
11
|
|
|
|
|
12
|
|
|
use Doctrine\Common\Annotations\Annotation\Attribute; |
|
13
|
|
|
use Doctrine\Common\Annotations\Annotation\Attributes; |
|
14
|
|
|
use Doctrine\Common\Annotations\Annotation\Target; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @Annotation |
|
18
|
|
|
* @Target("CLASS") |
|
19
|
|
|
* @Attributes({ |
|
20
|
|
|
* @Attribute("role", type="string"), |
|
21
|
|
|
* @Attribute("mapper", type="string"), |
|
22
|
|
|
* @Attribute("repository", type="string"), |
|
23
|
|
|
* @Attribute("table", type="string"), |
|
24
|
|
|
* @Attribute("database", type="string"), |
|
25
|
|
|
* @Attribute("source", type="string"), |
|
26
|
|
|
* @Attribute("constrain", type="string"), |
|
27
|
|
|
* @Attribute("columns", type="array<Cycle\Annotated\Annotation\Column>"), |
|
28
|
|
|
* }) |
|
29
|
|
|
*/ |
|
30
|
|
|
final class Entity |
|
31
|
|
|
{ |
|
32
|
|
|
/** @var string */ |
|
33
|
|
|
private $role; |
|
34
|
|
|
|
|
35
|
|
|
/** @var string */ |
|
36
|
|
|
private $mapper; |
|
37
|
|
|
|
|
38
|
|
|
/** @var string */ |
|
39
|
|
|
private $repository; |
|
40
|
|
|
|
|
41
|
|
|
/** @var string */ |
|
42
|
|
|
private $table; |
|
43
|
|
|
|
|
44
|
|
|
/** @var bool */ |
|
45
|
|
|
private $readonlySchema = false; |
|
46
|
|
|
|
|
47
|
|
|
/** @var string */ |
|
48
|
|
|
private $database; |
|
49
|
|
|
|
|
50
|
|
|
/** @var string */ |
|
51
|
|
|
private $source; |
|
52
|
|
|
|
|
53
|
|
|
/** @var string */ |
|
54
|
|
|
private $constrain; |
|
55
|
|
|
|
|
56
|
|
|
/** @var array<Column> */ |
|
57
|
|
|
private $columns = []; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param array $values |
|
61
|
|
|
*/ |
|
62
|
|
|
public function __construct(array $values) |
|
63
|
|
|
{ |
|
64
|
|
|
foreach ($values as $key => $value) { |
|
65
|
|
|
$this->$key = $value; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @return string|null |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getRole(): ?string |
|
73
|
|
|
{ |
|
74
|
|
|
return $this->role; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* @return string|null |
|
79
|
|
|
*/ |
|
80
|
|
|
public function getMapper(): ?string |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->mapper; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return string|null |
|
87
|
|
|
*/ |
|
88
|
|
|
public function getRepository(): ?string |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->repository; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* @return string|null |
|
95
|
|
|
*/ |
|
96
|
|
|
public function getTable(): ?string |
|
97
|
|
|
{ |
|
98
|
|
|
return $this->table; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @return bool |
|
103
|
|
|
*/ |
|
104
|
|
|
public function isReadonlySchema(): bool |
|
105
|
|
|
{ |
|
106
|
|
|
return $this->readonlySchema; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @return string|null |
|
111
|
|
|
*/ |
|
112
|
|
|
public function getDatabase(): ?string |
|
113
|
|
|
{ |
|
114
|
|
|
return $this->database; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* @return string|null |
|
119
|
|
|
*/ |
|
120
|
|
|
public function getSource(): ?string |
|
121
|
|
|
{ |
|
122
|
|
|
return $this->source; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* @return string|null |
|
127
|
|
|
*/ |
|
128
|
|
|
public function getConstrain(): ?string |
|
129
|
|
|
{ |
|
130
|
|
|
return $this->constrain; |
|
131
|
|
|
} |
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* @return Column[] |
|
135
|
|
|
*/ |
|
136
|
|
|
public function getColumns(): array |
|
137
|
|
|
{ |
|
138
|
|
|
return $this->columns; |
|
139
|
|
|
} |
|
140
|
|
|
} |