1. Go to this page and download the library: Download naprstek/acl-entity 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/ */
naprstek / acl-entity example snippets
namespace AclEntity\Tests\Entity;
use AclEntity\IEntity;
use AclEntity\Entity\Entity;
use AclEntity\Annotation\Acl;
class Element extends Entity implements IEntity {
/**
* @var integer
* @Acl({"view":{"internal", "external"}, "edit":{}})
*/
private $id;
/**
* @var string
* @Acl({"view":{"internal"}, "edit":{"external"}})
*/
private $name;
/**
* @var string
* @Acl({"view":{"external"}, "edit":{"internal"}})
*/
private $value;
}
//Roles
$this->addRole(new Role('internal'));
$this->addRole(new Role('external'));
//Resources: it is our data propertis
$my = new Element();
foreach($my->getAllProperties() as $resource) {
$this->addResource(new Resource($resource));
}
//define privilleges
$this->allow('internal', $my->getAclProperties('internal', 'view'), 'view');
$this->allow('internal', $my->getAclProperties('internal', 'edit'), 'edit');
$this->allow('external', $my->getAclProperties('external', 'view'), 'view');
$this->allow('external', $my->getAclProperties('external', 'edit'), 'edit');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.