Skip to content

Commit

Permalink
Merge back
Browse files Browse the repository at this point in the history
  • Loading branch information
dvlpp committed Jun 27, 2024
2 parents 2971f41 + 219e9de commit e91c745
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions docs/guide/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,31 +378,32 @@ Dashboard can use Commands too, with a very similar API, apart for:

## Bulk Commands (Entity List only)

As seen before, Entity Commands are executed on multiple instances: all of them, or a filtered list of them. But sometimes you may need to execute a Command on a specific list of instances, a user selection.
As seen before, Entity Commands are executed on multiple instances: either all of them, or a sublist based on active filters. But sometimes you may need to execute a Command on a custom list of instances, crafted by the user. In order to allow that, you can:

In order to allow that, you must:

### Configure the Command to allow an instance selection
### Configure the Entity Command to allow an instance selection

```php
class PostList extends SharpEntityList
class MyBulkCommand extends EntityCommand
{
// [...]

public function buildCommandConfig(): void
{
$this->configureInstanceSelectionAllowed();
}
}
```

::: tip
You may use `configureInstanceSelectionRequired()` instead to declare that the command can not be executed without a selection.
:::

### Apply the Command to the selected instances

You can use the `$this->selectedIds()` method to retrieve the list of selected instances ids, and apply the Command to them:
Use the `$this->selectedIds()` method to retrieve the list of selected instances ids and apply the Command to them; for instance:

```php
class PostList extends SharpEntityList
class MyBulkCommand extends EntityCommand
{
// [...]

Expand Down

0 comments on commit e91c745

Please sign in to comment.