Skip to content
This repository was archived by the owner on Feb 13, 2023. It is now read-only.

Commit c40ecef

Browse files
rprzedzikwfajczyk
andauthored
Add mass action cookbook (#45)
* Add mass action cookbook * Update docs/backend/cookbook/new_mass_action.md Co-authored-by: wfajczyk <37833669+wfajczyk@users.noreply.github.com>
1 parent 0ce464b commit c40ecef

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

docs/backend/cookbook.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@
1010
* [New Grid Column Type](backend/cookbook/new_grid_column_type.md)
1111
* [New Condition](backend/cookbook/new_condition.md)
1212
* [New Channel](backend/cookbook/new_channel.md)
13+
* [New Mass Action](backend/cookbook/new_mass_action.md)
1314

1415

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# How to create new mass action
2+
3+
## Mass action processor class
4+
5+
Any custom mass action process must implement ```BatchActionProcessorInterface```
6+
7+
```php
8+
namespace YourNameSpace\Infrastructure\Processor;
9+
10+
use Ergonode\BatchAction\Domain\Entity\BatchActionId;
11+
use Ergonode\BatchAction\Domain\ValueObject\BatchActionMessage;
12+
use Ergonode\BatchAction\Domain\ValueObject\BatchActionType;
13+
use Ergonode\BatchAction\Infrastructure\Provider\BatchActionProcessorInterface;
14+
use Ergonode\SharedKernel\Domain\AggregateId;
15+
16+
class YourBatchActionProcessor implements BatchActionProcessorInterface
17+
{
18+
public function supports(BatchActionType $type): bool
19+
{
20+
return $type->getValue() === 'you type';
21+
}
22+
23+
/**
24+
* @return BatchActionMessage[]
25+
*/
26+
public function process(BatchActionId $id, AggregateId $resourceId): array
27+
{
28+
// here implement your action for given AggregateId
29+
}
30+
}
31+
```
32+
33+
If, for some reason, a mass action can't be processed for a given object, you can return information about it as array of ```BatchActionMessage``` objects
34+
In whole batch action this object is marked processed as unsuccessful.

0 commit comments

Comments
 (0)