Skip to content

Commit e305abd

Browse files
authored
Add documentation on command translation. (#41135)
* Add documentation on command translation. * Restyle * Rephrased things a bit. * Restyle
1 parent fa29d36 commit e305abd

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

docs/guides/migrating_ember_cluster_to_code_driven.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,31 @@ new code-driven class structure.
105105

106106
#### Command Handling
107107

108-
- Translate `emberAf...Callback` functions into logic inside your
109-
`InvokeCommand` method.
108+
- Translate `CommandHandlerInterface` calls or `emberAf...Callback` functions
109+
into logic inside your `InvokeCommand` method:
110+
111+
- ember calls of the form `emberAf<CLUSTER>Cluster<COMMAND>Callback` will
112+
be converted to a switch `case <CLUSTER>::Commands::<COMMAND>::Id: ...`
113+
implementation
114+
115+
Example:
116+
117+
```cpp
118+
// This
119+
emberAfAccessControlClusterReviewFabricRestrictionsCallback(...);
120+
121+
// Becomes this in the `InvokeCommand` implementation:
122+
switch (request.path.mCommandId) {
123+
// ...
124+
case AccessControl::Commands::ReviewFabricRestrictions::Id:
125+
// ...
126+
}
127+
```
128+
129+
- Command Handler Interface logic translates directly: `CHI` has a switch
130+
on command ID inside its `InvokeCommand` call. You should have the same
131+
logic inside the `ServerClusterInterface` processing logic.
132+
110133
- The `InvokeCommand` method can return an `ActionReturnStatus` optional. For
111134
better readability, prefer returning a status code directly (e.g.,
112135
`return Status::Success;`) rather than using the command handler to set the

0 commit comments

Comments
 (0)