Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit bf7bd05

Browse files
committed
Changes as requested per mwop
1 parent a0373dc commit bf7bd05

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

doc/book/usage.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,38 @@ rule that is directly applicable to the query. In this case, since the "member"
104104
before the "guest" role, the example code would print "allowed".
105105

106106

107-
### LIFO/FILO order for Role parents
107+
### LIFO order for Role parents
108108

109109
When specifying multiple parents for a role the last parent listed is the first
110-
one searched for rules applicable to an authorization query. This Last-In-First-Out
111-
(aka First-In-Last-Out) strategy is represented with this example.
112-
Here the `first` role is the highest order:
110+
one searched for rules applicable to an authorization query. This Last-In-First-Out strategy is represented with this example.
111+
Here the `first` role inherits from `second`, `third`, and `last` and is the most permissioned role:
112+
```php
113+
use Zend\Permissions\Acl\Acl;
114+
use Zend\Permissions\Acl\Role\GenericRole as Role;
115+
use Zend\Permissions\Acl\Resource\GenericResource as Resource;
116+
117+
$acl = new Acl();
118+
119+
$acl->addRole(new Role('last'))
120+
->addRole(new Role('third'))
121+
->addRole(new Role('second'));
113122

114-
```
115123
$acl->addRole(new Role('first'), ['last', 'third', 'second']);
124+
125+
$acl->addResource(new Resource('someResource'));
126+
127+
$acl->deny('last', 'someResource');
128+
$acl->allow('third', 'someResource');
129+
130+
// allowed
131+
echo $acl->isAllowed('first', 'someResource') ? 'allowed' : 'denied';
116132
```
117133

118-
Less-permissioned roles will be first in the parents array. For instance, where a`guest`
134+
Less-permissioned roles will be first in the parents array. For instance, where a`guest`
119135
role is unauthenticated, a `user` role is authenticated, and an `admin` role has the highest
120-
permissions, adding the `admin` role is as follows:
136+
permissions. As soon as any ACL query returns false evaluation of `isAllowed` is terminated and false is returned. For this reason your least permissioned roles come first in the parents array. Adding the `admin` role is as follows:
121137

122-
```
138+
```php
123139
$acl->addRole(new Role('admin'), ['guest', 'user']);
124140
```
125141

0 commit comments

Comments
 (0)