manuxi/sulu-bulk-actions-bundle

Bulk Actions for Sulu bundles.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

Language:JavaScript

Type:symfony-bundle

pkg:composer/manuxi/sulu-bulk-actions-bundle

0.1.0 2025-10-22 23:57 UTC

This package is auto-updated.

Last update: 2025-10-26 12:25:05 UTC


README

License: MIT GitHub Tag Supports Sulu 2.6 or later

I made this bundle to have the possibility to manage bulk actions in lists of my projects.

Please feel comfortable submitting feature requests. This bundle is still in development. Use at own risk 🤞🏻

👩🏻‍🏭 Installation

Some tasks are awaiting you!

Install the package with:

composer require manuxi/sulu-bulk-actions-bundle

Rebuild admin sources:

    cd assets/admin
    npm install
    npm run build
  1. Then add the config for resourcekey and actions to Admin in project/bundle
    public function getConfigKey(): ?string
    {
        return 'sulu_mybundle';
    }

    public function getConfig(): ?array
    {
        return [
            'resourceKey' => 'mybundle',  //with this, the route is build: /admin/api/{resourceKey}/bulk-{action}
            'bulkActions' => [
                'publish' => ['icon' => 'su-eye'],
                'unpublish' => ['icon' => 'su-eye-slash'],
            ],
        ];
    }
  1. The action-buttons must be added to the Admin-Class in project/bundle
    $listToolbarActions[] = new ToolbarAction('app.bulk.actions_dropdown', [
        'label' => 'sulu_bulk_actions.actions',
        'icon' => 'su-pen',
        'actions' => [
            'app.bulk.publish',
            'app.bulk.unpublish',
        ],
    ]);
  1. Add a handler in project/bundle
    class MybundleBulkActionHandler
    {
        public function __construct(
            private readonly MybundleModel $model,
        ) {
        }
    
        public function supports(string $resourceKey, string $action): bool
        {
            return 'testimonials' === $resourceKey
                && in_array($action, ['publish', 'unpublish']);
        }
    
        public function handle(string $action, array $ids, Request $request): array
        {
            return match ($action) {
                'publish' => $this->tmodel->publishBulk($ids, $request),
                'unpublish' => $this->model->unpublishBulk($ids, $request),
                default => [],
            };
        }
    }

Thats maily all.