You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: core/state-processors.md
+35-29Lines changed: 35 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ However, you may want to:
13
13
14
14
* store data to other persistence layers (Elasticsearch, external web services...)
15
15
* not publicly expose the internal model mapped with the database through the API
16
-
* use a separate model for [read operations](data-providers.md) and for updates by implementing patterns such as [CQRS](https://martinfowler.com/bliki/CQRS.html)
16
+
* use a separate model for [read operations](state-providers.md) and for updates by implementing patterns such as [CQRS](https://martinfowler.com/bliki/CQRS.html)
17
17
18
18
Custom state processors can be used to do so. A project can include as many state processors as needed. The first able to
19
19
process the data for a given resource will be used.
To create a state processor, you have to implement the [`ProcessorInterface`](https://github.com/api-platform/core/blob/main/src/State/ProcessorInterface.php).
30
-
This interface defines only two methods:
31
-
32
-
*`process`: to create, delete, update, or process the given data in any ways
33
-
*`supports`: to check whether the given data is supported by this state processor
30
+
This interface defines a method `process`: to create, delete, update, or alter the given data in any ways.
34
31
35
32
Here is an implementation example:
36
33
@@ -47,36 +44,40 @@ class BlogPostProcessor implements ProcessorInterface
47
44
/**
48
45
* {@inheritDoc}
49
46
*/
50
-
public function process($data, array $identifiers = [], ?string $operationName = null, array $context = [])
47
+
public function process($data, Operation $operation, array $uriVariables = [], array $context = [])
51
48
{
52
49
// call your persistence layer to save $data
53
50
return $data;
54
51
}
55
-
56
-
/**
57
-
* {@inheritDoc}
58
-
*/
59
-
public function supports($data, array $identifiers = [], ?string $operationName = null, array $context = []): bool
0 commit comments