The Restriction Feature is disabled by default. So activate it first:
members:
restriction:
enabled: true
Note: You need to create some groups before you can enable the restrictions.
Once activated, you'll see a restriction tab in every document.
If your enable the inheritance checkbox, all child objects will inherit the restriction.
If you're adding a new child element to a inheritable document, it will automatically adopt the restriction.
If you want to restrict object, you need to define them in the members configuration first:
members:
restriction:
enabled: true
allowed_objects:
- 'NewsEntry'
- 'YourObjectName'
Now you should see a restriction tab in all of those defined objects.
If your enable the inheritance checkbox, all child objects will inherit the restriction.
If you're adding a new child element to a inheritable object, it will automatically adopt the restriction.
After you've activated the restriction globally, you're able to restrict assets.
Important: Only Assets within the /restricted-assets
folder are able to restrict!
Since assets can't have child assets you need to create a folder first. Open the folder, and you'll see the inheritance checkbox. If you activate it, all assets will inherit all the restriction information from this folder.
If you're adding a new asset into a inheritable folder, it will automatically adopt the restriction.
To get current restriction information about a document, object or asset, just call the restriction manager:
<?php
use MembersBundle\Manager\RestrictionManager;
$element = Pimcore\Model\Asset::getById(1);
/** @var \MembersBundle\Restriction\ElementRestriction $restriction */
$restriction = $this->container->get(RestrictionManager::class)->getElementRestrictionStatus($element);
//get restriction group ids
echo $restriction->getRestrictionGroups();
//get section
echo $restriction->getSection();
//get state
echo $restriction->getState();