|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace LAG\AdminBundle\Metadata\Property; |
|
6
|
|
|
|
|
7
|
|
|
abstract class AbstractProperty implements PropertyInterface |
|
8
|
|
|
{ |
|
9
|
|
|
public function __construct( |
|
10
|
|
|
private string $name, |
|
11
|
|
|
private ?string $propertyPath, |
|
12
|
|
|
private ?string $label = null, |
|
13
|
|
|
private ?string $template = null, |
|
14
|
|
|
private bool $mapped = true, |
|
15
|
|
|
private bool $sortable = true, |
|
16
|
|
|
private bool $translation = false, |
|
17
|
|
|
private ?string $translationDomain = 'admin', |
|
18
|
|
|
private array $attr = [], |
|
19
|
|
|
private array $headerAttr = [], |
|
20
|
|
|
) { |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
public function getName(): string |
|
24
|
|
|
{ |
|
25
|
|
|
return $this->name; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function withName(string $property): self |
|
29
|
|
|
{ |
|
30
|
|
|
$self = clone $this; |
|
31
|
|
|
$self->name = $property; |
|
32
|
|
|
|
|
33
|
|
|
return $self; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function getPropertyPath(): ?string |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->propertyPath; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function withPropertyPath(?string $propertyPath): self |
|
42
|
|
|
{ |
|
43
|
|
|
$self = clone $this; |
|
44
|
|
|
$self->propertyPath = $propertyPath; |
|
45
|
|
|
|
|
46
|
|
|
return $self; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function getLabel(): ?string |
|
50
|
|
|
{ |
|
51
|
|
|
return $this->label; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function withLabel(?string $label): self |
|
55
|
|
|
{ |
|
56
|
|
|
$self = clone $this; |
|
57
|
|
|
$self->label = $label; |
|
58
|
|
|
|
|
59
|
|
|
return $self; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function getTemplate(): ?string |
|
63
|
|
|
{ |
|
64
|
|
|
return $this->template; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function withTemplate(?string $template): self |
|
68
|
|
|
{ |
|
69
|
|
|
$self = clone $this; |
|
70
|
|
|
$self->template = $template; |
|
71
|
|
|
|
|
72
|
|
|
return $self; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
public function isMapped(): bool |
|
76
|
|
|
{ |
|
77
|
|
|
return $this->mapped; |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function withMapped(bool $mapped): self |
|
81
|
|
|
{ |
|
82
|
|
|
$self = clone $this; |
|
83
|
|
|
$self->mapped = $mapped; |
|
84
|
|
|
|
|
85
|
|
|
return $self; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function isSortable(): bool |
|
89
|
|
|
{ |
|
90
|
|
|
return $this->sortable; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function withSortable(bool $sortable): self |
|
94
|
|
|
{ |
|
95
|
|
|
$self = clone $this; |
|
96
|
|
|
$self->sortable = $sortable; |
|
97
|
|
|
|
|
98
|
|
|
return $self; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function isTranslation(): bool |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->translation; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function withTranslation(bool $translation): self |
|
107
|
|
|
{ |
|
108
|
|
|
$self = clone $this; |
|
109
|
|
|
$self->translation = $translation; |
|
110
|
|
|
|
|
111
|
|
|
return $self; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
public function getTranslationDomain(): ?string |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->translationDomain; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function withTranslationDomain(?string $translationDomain): self |
|
120
|
|
|
{ |
|
121
|
|
|
$self = clone $this; |
|
122
|
|
|
$self->translationDomain = $translationDomain; |
|
123
|
|
|
|
|
124
|
|
|
return $self; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function getAttr(): array |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->attr; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function withAttr(array $attr): self |
|
133
|
|
|
{ |
|
134
|
|
|
$self = clone $this; |
|
135
|
|
|
$self->attr = $attr; |
|
136
|
|
|
|
|
137
|
|
|
return $self; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
public function getHeaderAttr(): array |
|
141
|
|
|
{ |
|
142
|
|
|
return $this->headerAttr; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
public function withHeaderAttr(array $headerAttr): self |
|
146
|
|
|
{ |
|
147
|
|
|
$self = clone $this; |
|
148
|
|
|
$self->headerAttr = $headerAttr; |
|
149
|
|
|
|
|
150
|
|
|
return $self; |
|
151
|
|
|
} |
|
152
|
|
|
} |
|
153
|
|
|
|