perspeqtive / sulu-permission-aware-collections-bundle
Applies Sulu access control permissions to media collections in the Sulu admin
Package info
github.com/perspeqtive/sulu-permission-aware-collections-bundle
Type:sulu-bundle
pkg:composer/perspeqtive/sulu-permission-aware-collections-bundle
Requires
- php: ^8.2
- ext-simplexml: *
- doctrine/orm: ^3.3
- perspeqtive/sulu-access-control-custom-query-enhancer-bundle: ^3.0
- sulu/sulu: ^3.0.11
Requires (Dev)
- php-cs-fixer/shim: ^3.75
- phpstan/phpstan: ^2.1
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^12
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The Sulu Permission Aware Collections Bundle applies the access control of media collections to every collection query in the Sulu admin. Sulu itself filters collections by permission only where it asks for it explicitly — the collection tree, the sub collection and media counters, breadcrumbs and the collection search still show collections the current user is not allowed to view. This bundle moves the permission filter into the repository, so a collection without view permission is invisible everywhere in the admin, while the website keeps seeing all collections.
No configuration is needed: the permissions you already maintain per collection in the Sulu admin are the ones being applied.
🚀 Features
- Collections without view permission disappear from the collection tree, the media overview, the breadcrumb and the collection search
- Uses the permissions configured per collection in the Sulu admin — no additional configuration
- Only active inside the
adminfirewall, the website is served by Sulu's own repository - Registers as access control descendant provider, so permissions keep being inherited to sub collections
🛠️ Installation
Install the bundle via Composer:
composer require perspeqtive/sulu-permission-aware-collections-bundle
Enable the bundles
Register them in your config/bundles.php:
return [ // ... PERSPEQTIVE\SuluAccessControlCustomQueryEnhancerBundle\SuluAccessControlCustomQueryEnhancerBundle::class => ['all' => true], PERSPEQTIVE\SuluPermissionAwareCollectionsBundle\SuluPermissionAwareCollectionsBundle::class => ['all' => true], ];
That is all the setup there is — the bundle has no configuration.
🛠️ Usage
Assign the permissions as usual in the Sulu admin: Media → select a collection → Permissions, then grant or revoke view for the roles in question. From that moment on the collection is only part of any admin query for users whose role has the view permission.
Permissions are inherited: revoking view on a collection hides its sub collections as well.
👩🍳 Contribution
Please feel free to fork and extend existing or add new features and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and adapt the documentation.