add documentation for global batch actions
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
7f4335353f
commit
5142ac39ab
1 changed files with 30 additions and 0 deletions
|
|
@ -307,3 +307,33 @@ $configuration->setBatchAction(
|
|||
}
|
||||
);
|
||||
```
|
||||
|
||||
## setGlobalBatchAction
|
||||
|
||||
`setGlobalBatchAction(string $context, string $action, string $label, callable $callack)`
|
||||
|
||||
Add a global batch action. The callback has 3 arguments:
|
||||
|
||||
* An instance of `App\Core\Repository\RepositoryQuery`
|
||||
* An instance of `App\Core\Manager\EntityManager`
|
||||
* An array of selected entities or a `null` value
|
||||
|
||||
Do not use the same action in global and classic batch action.
|
||||
|
||||
The callback can return a response. If not, the user will be redirect automatically. See the example below:
|
||||
|
||||
```php-inline
|
||||
use App\Core\Entity\EntityInterface;
|
||||
use App\Core\Manager\EntityManager;
|
||||
|
||||
$configuration->setGlobalBatchAction(
|
||||
'index',
|
||||
'export_json',
|
||||
'Export to JSON',
|
||||
function(RepositoryQuery $query, EntityManager $manager, ?array $selection): ?Response {
|
||||
$items = $selection ?? $query->find();
|
||||
|
||||
return $this->json($items);
|
||||
}
|
||||
);
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue