Commit 5c3bd6ab by Alexander Makarov

Merge pull request #2077 from lucianobaraglia/authorization-doc-update

Authorization doc match callback example
parents 362ade63 e64e35fb
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment