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