1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
class Test
{
public function read()
{
}
public function write()
{
}
public function delete()
{
}
}
$acl = new Zend_Acl();
$acl->addResource(new Zend_Acl_Resource('test'));
$acl->addRole(new Zend_Acl_Role('guest'))
->addRole(new Zend_Acl_Role('writer'), 'guest')
->addRole(new Zend_Acl_Role('admin'), 'writer');
$acl->allow('guest', 'test', 'read')
->allow('writer', 'test', 'write')
->allow('admin', 'test', 'delete');
Zend_Debug::dump($acl->isAllowed('guest', 'test', 'delete'));
Zend_Debug::dump($acl->isAllowed('admin', 'test', 'delete'));
Zend_Debug::dump($acl->isAllowed('writer', 'test', 'write')); |
Partager