Yii v2 snippet guide

Comparing #114 with #115

Revision #115 was created by rackycz rackycz on Sep 27, 2019, 7:40:47 AM.

edit

Content

[...]
```

As you can see in the snippet above, other controllers must contain row "use app\controllers\BaseController" + "extends BaseController"


**
ASimple access rights**
---
Every controller can allow different users/guests to use different actions. Method behaviors() can be used to do this. If you generate the controller using GII the method will be present and you will just add the "access-part" like this:
[...]
'roles' => ['@'], // logged in users
// 'roles' => ['?'], // guests
 // 'matchCallback' => function ($rule, $action) { // all logged in users are redirected to some other page // just for demonstration of matchCallback  // return $this->redirect('index.php?r=user/create');  // }
],
],
[...]
```

.. This is all I needed so far. I will add more complex snippet as soon as I need it ...
 
 
Details can be found here [https://www.yiiframework.com/doc/guide/2.0/en/security-authorization](https://www.yiiframework.com/doc/guide/2.0/en/security-authorization).

**Nice URLs**
---
... text ...
[...]