1. Go to this page and download the library: Download gtt/reverse-search-acl library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gtt / reverse-search-acl example snippets
use Gtt\Acl\Dbal\ReverseSearchAclProvider;
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
use Symfony\Component\Security\Acl\Permission\BasicPermissionMap;
use Symfony\Component\Security\Acl\Permission\BasicPermissionMap;
use Doctrine\DBAL\DriverManager;
$provider = new ReverseSearchAclProvider(
new BasicPermissionMap()
DriverManager::getConnection(['driver' => 'pdo_sqlite','memory' => true],
new PermissionGrantingStrategy(),
[] // list of base acl provider options
);
$sid = UserSecurityIdentity::fromAccount(new User('jimmy', 'jimmypass'));
// you can also analyse roles
// $sid = new RoleSecurityIdentity('ROLE_ADMIN');
$allowed = $provider->findAllowedEntries($sid, "VIEW")
[
// the key is FQCN of the class of the object that can be accessed by specified Security Identity instance (SID)
'\F\Q\C\N' => [
// if this flag is presented class ace was inserted for current SID
'class_access' => true,
// list of class field's granted to current SID
'class_field_access' => ['field1', 'field2', 'field3'],
// id of the domain objects accessible by current SID
'object_access' => ['id1', 'id2', 'id3', 'id4'],
// list of domain object fields (grouped by object id) granted to current SID
'object_field_access' => [
'id2' => ['field1', 'field2'],
'id5' => ['field3']
]
]
]