Yii v2 snippet guide

Comparing #130 with #131

Revision #131 was created by rackycz rackycz on Oct 4, 2019, 12:11:08 PM.

contact

Content

[...]
```php
<p>
Note that if you turn on the Yii debugger ...
```

Then some security - filtering users in the new ContactController:
 
 
```php
 
public function beforeAction($action) {
 
 
  if (!parent::beforeAction($action)) {
 
    return false;
 
  }
 
 
  $guestAllowedActions = [];
 
 
  if (Yii::$app->user->isGuest) {
 
    if (!in_array($action->actionMethod, $guestAllowedActions)) {
 
      return $this->redirect(['site/index']);
 
    }
 
  }
 
  
 
  return true;
 
}
 
```
 
 
**Tests - unit + opa** --- ... text ...