Download the PHP package fontis/customergroupaccess-mage2 without Composer
On this page you can find all versions of the php package fontis/customergroupaccess-mage2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fontis/customergroupaccess-mage2
More information about fontis/customergroupaccess-mage2
Files in fontis/customergroupaccess-mage2
Package customergroupaccess-mage2
Short Description Provides a convenience class for implementing customer group based access in your Magento 2 extension.
License OSL-3.0
Informations about the package customergroupaccess-mage2
Fontis Magento 2 Customer Group Access
This is a standalone package designed to help extensions limit access to functionality such as payment methods to certain customer groups.
This is NOT a Magento 2 extension. It will not do anything by itself. It is intended for developers to use while implementing extensions.
The recommended way to install this package is to make your extension depend on
this package in its composer.json
file. To do so, add the following line to
the require
section of the file:
Once you've added this package as a dependency, follow these instructions for actually using the package within your extension:
-
Add two settings to your system.xml file, using the relevant source models:
- This
customer_group_access
withFontis\CustomerGroupAccess\Source\CustomerGroupAccess
- That
customer_group
withFontis\CustomerGroupAccess\Source\CustomerGroup
- This
-
In your
di.xml
file, define avirtualType
. TheconfigPathPrefix
should be the section and group IDs that contain the settings you added above.Using this example, the full path to one of the settings would be like so:
-
Use the virtualType to configure the model where your access checks need to be performed:
-
In your model's constructor, accept this class as one of the arguments:
-
When you actually need to perform the access check, use the factory to create an instance of the access check class. If you need to perform the check in the context of a store that isn't the current store, you'll need to pass in a store ID:
- Perform the check by calling the
check()
method and passing it a customer group ID. If it returns true, they're allowed to use whatever it is you're offering. If it returns false, they aren't. Simple!
All versions of customergroupaccess-mage2 with dependencies
magento/framework Version 100.*|101.*|102.*|103.*
magento/module-customer Version 100.*|101.*|102.*|103.*
magento/module-store Version 100.*|101.*|103.*