Download the PHP package monsieurbiz/sylius-plus-adapter-plugin without Composer
On this page you can find all versions of the php package monsieurbiz/sylius-plus-adapter-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download monsieurbiz/sylius-plus-adapter-plugin
More information about monsieurbiz/sylius-plus-adapter-plugin
Files in monsieurbiz/sylius-plus-adapter-plugin
Package sylius-plus-adapter-plugin
Short Description This plugin offer tools to adapt your plugins to Sylius Plus RBAC system.
License MIT
Informations about the package sylius-plus-adapter-plugin
Sylius Plus Adapter Plugin
This plugin offer tools to adapt your plugins to Sylius Plus RBAC system.
Compatibility
| Sylius Version | PHP Version |
|---|---|
| 1.12 | 8.1 - 8.2 - 8.3 |
| 1.13 | 8.1 - 8.2 - 8.3 |
| 1.14 | 8.1 - 8.2 - 8.3 |
Installation
How to use
To illustrate the following examples, we will use a Foo plugin with a MyResource resource.
Your resource entity
Your resource config
Add permissions on routes
It's a Sylius native feature, you don't have to install this plugin!
You just have to add permission: true on your route definition.
If you do this, your route will become available on the permission tree.
Example
Add channel restriction on resources
If you want to add channel restrictions on your channel related resources, you have to following theses 2 steps:
- Your resource (entity) need to implement
\Sylius\Component\Channel\Model\ChannelAwareInterfaceor\Sylius\Component\Channel\Model\ChannelsAwareInterface. - You need to include the
\MonsieurBiz\SyliusPlusAdapterPlugin\DependencyInjection\SyliusPlusCompatibilityTraittrait in your bundle extension class and call theprependRestrictedResourcesmethod in theprependmethod.
Example
Your plugin extension file
Filter resource grid with channel restriction
To filter the resource grid with channel restriction, you need to include the \MonsieurBiz\SyliusPlusAdapterPlugin\DependencyInjection\SyliusPlusCompatibilityTrait
trait in your bundle extension class and call the replaceInGridOriginalQueryBuilderWithChannelRestrictedQueryBuilder method in the prepend method.
The goal of this is to replace the original query builder of the grid with a new one that call the original one but will filter the resources with the current channel if needed.
Configuring this is tricky so follow the example below.
Example
Your current resource grid config
Your plugin extension file
Filter channel choice type with channel restriction
To filter the channel choice type with channel restriction, you need to include the \MonsieurBiz\SyliusPlusAdapterPlugin\DependencyInjection\SyliusPlusCompatibilityTrait and call the enabledFilteredChannelChoiceType method in the load method.
Example
Your current resource form type
Your plugin extension file
Development
Because this plugin is a kind of sidekick for your plugins, it's not intended to be used in a standalone project.
Even more because it requires Sylius Plus to be useful. Our traditional test application then seems useless.
But to be fair, we still added a test app with our CMS plugin installed and configured to use the SyliusPlusCompatibilityTrait trait.
It would be useful to be sure that everything is working as expected in a normal Sylius even if this plugin is installed and used.
License
This plugin is under the MIT license. Please see the LICENSE file for more information.