-
-
Notifications
You must be signed in to change notification settings - Fork 838
/
filter-notes
61 lines (48 loc) · 1.59 KB
/
filter-notes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
```php
// how to give uidfilter the parameters it should declare?
// is it automatic if we find a property having the uid type?
#[Get(filters: [new SearchFilter(), new UidFilter()])
#[Parameter('key', schema: ['type' => 'string'])] // add transform + validate extension points
class Book {
}
final class Parameter {
mixed $value;
?string $property;
?string $class;
array $attributes;
}
class FilterInterface {}
class UidFilter {
public function __construct(private readonly string $class) {}
public function parseQueryParameter(array $queryParameters = []): Parameter[] {
return [
new Parameter(value: '', attributes: ['operation' => 'and'])
];
}
// Query parameter type
public function getSchema(): array {
return ['type' => 'string'];
}
public function getOpenApiParameter(): OpenApi\Parameter {
return ...;
}
}
public function process(Operation $operation) {
$request = $context['request'];
foreach($operation->getFilters() as $filter) {
foreach ($filter->parseQueryParameter($request->query, $context) as $parameter) {
$this->queryParameterValidator->validate($filter, $parameter, $context);
$filter->execute($filter, $parameter, $context);
}
}
}
```
TODO:
see SerializerFilterContextBuilder: public function apply(Request $request, bool $normalization, array $attributes, array &$context): void;
maybe something like:
```
class SerializerFilterInterface {
public function getNormalizationContext(...);
public function getDenormalizationContext(...);
}
```