Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
5c3bd6ab
Commit
5c3bd6ab
authored
Jan 20, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2077 from lucianobaraglia/authorization-doc-update
Authorization doc match callback example
parents
362ade63
e64e35fb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
authorization.md
docs/guide/authorization.md
+13
-2
No files found.
docs/guide/authorization.md
View file @
5c3bd6ab
...
...
@@ -57,10 +57,10 @@ class SiteController extends Controller
return
[
'access'
=>
[
'class'
=>
\yii\web\AccessControl
::
className
(),
'only'
=>
[
'special'
],
'only'
=>
[
'special
-callback
'
],
'rules'
=>
[
[
'actions'
=>
[
'special'
],
'actions'
=>
[
'special
-callback
'
],
'allow'
=>
true
,
'matchCallback'
=>
function
(
$rule
,
$action
)
{
return
date
(
'd-m'
)
===
'31-10'
;
...
...
@@ -68,6 +68,17 @@ class SiteController extends Controller
],
```
And the action:
```
php
// ...
// Match callback called! This page can be accessed only each October 31st
public
function
actionSpecialCallback
()
{
return
$this
->
render
(
'happy-halloween'
);
}
```
Sometimes you want a custom action to be taken when access is denied. In this case you can specify
`denyCallback`
.
Role based access control (RBAC)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment