1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace LAG\AdminBundle\Metadata\Filter; |
6
|
|
|
|
7
|
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType; |
8
|
|
|
|
9
|
|
|
#[\Attribute] |
10
|
|
|
class Filter implements FilterInterface |
11
|
|
|
{ |
12
|
|
|
public function __construct( |
13
|
|
|
private string $name, |
14
|
|
|
private ?string $propertyPath = null, |
15
|
|
|
private string $comparator = '=', |
16
|
|
|
private string $operator = 'and', |
17
|
|
|
private mixed $data = null, |
18
|
|
|
private string $formType = TextType::class, |
19
|
|
|
private array $formOptions = [], |
20
|
|
|
) { |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function getName(): string |
24
|
|
|
{ |
25
|
|
|
return $this->name; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function withName(string $name): self |
29
|
|
|
{ |
30
|
|
|
$self = clone $this; |
31
|
|
|
$self->name = $name; |
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 getComparator(): string |
50
|
|
|
{ |
51
|
|
|
return $this->comparator; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function withComparator(string $comparator): self |
55
|
|
|
{ |
56
|
|
|
$self = clone $this; |
57
|
|
|
$self->comparator = $comparator; |
58
|
|
|
|
59
|
|
|
return $self; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getOperator(): string |
63
|
|
|
{ |
64
|
|
|
return $this->operator; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function withOperator(string $operator): self |
68
|
|
|
{ |
69
|
|
|
$self = clone $this; |
70
|
|
|
$self->operator = $operator; |
71
|
|
|
|
72
|
|
|
return $self; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getData(): mixed |
76
|
|
|
{ |
77
|
|
|
return $this->data; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function withData(mixed $data): self |
81
|
|
|
{ |
82
|
|
|
$self = clone $this; |
83
|
|
|
$self->data = $data; |
84
|
|
|
|
85
|
|
|
return $self; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function getFormType(): string |
89
|
|
|
{ |
90
|
|
|
return $this->formType; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
public function withFormType(string $formType): FilterInterface |
94
|
|
|
{ |
95
|
|
|
$self = clone $this; |
96
|
|
|
$self->formType = $formType; |
97
|
|
|
|
98
|
|
|
return $self; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
public function getFormOptions(): array |
102
|
|
|
{ |
103
|
|
|
return $this->formOptions; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function withFormOptions(array $formOptions): FilterInterface |
107
|
|
|
{ |
108
|
|
|
$self = clone $this; |
109
|
|
|
$self->formOptions = $formOptions; |
110
|
|
|
|
111
|
|
|
return $self; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|