From e64e35fb991de8cd1eab37f7b2f816dd35642201 Mon Sep 17 00:00:00 2001 From: Luciano Baraglia Date: Mon, 20 Jan 2014 14:03:07 -0300 Subject: [PATCH] Authorization doc match callback example --- docs/guide/authorization.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/guide/authorization.md b/docs/guide/authorization.md index 568b3b46ad..df40f2fae4 100644 --- a/docs/guide/authorization.md +++ b/docs/guide/authorization.md @@ -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)