Skip to content

Commit 47eb965

Browse files
committed
[skip ci] update README
1 parent 03f3db7 commit 47eb965

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,29 @@ class TestAclController extends ControllerBase {
6262
}
6363
```
6464

65+
#### Overriding
66+
It is necessary to override the _getRole method so that it returns the role of the active user:
67+
68+
```php
69+
namespace controllers;
70+
use Ubiquity\attributes\items\acl\Resource;
71+
use Ubiquity\attributes\items\acl\Allow;use Ubiquity\utils\http\USession;
72+
use Ubiquity\utils\http\USession;
73+
74+
#[Resource('Main')]
75+
#[Allow(role: '@USER')]
76+
class TestAclController extends ControllerBase {
77+
use AclControllerTrait;
78+
79+
public function _getRole(){
80+
$activeUser=USession::get('activeUser');
81+
if(isset($activeUser)){
82+
return $activeUser->getRole();
83+
}
84+
}
85+
}
86+
```
87+
6588
### Defining ACLs with Database
6689
The ACLs defined in the database are additional to the ACLs defined via annotations or attributes.
6790

0 commit comments

Comments
 (0)