yii\web\User::beforeLogout PHP Метод

beforeLogout() защищенный Метод

The default implementation will trigger the [[EVENT_BEFORE_LOGOUT]] event. If you override this method, make sure you call the parent implementation so that the event is triggered.
protected beforeLogout ( yii\web\IdentityInterface $identity ) : boolean
$identity yii\web\IdentityInterface the user identity information
Результат boolean whether the user should continue to be logged out
    protected function beforeLogout($identity)
    {
        $event = new UserEvent(['identity' => $identity]);
        $this->trigger(self::EVENT_BEFORE_LOGOUT, $event);
        return $event->isValid;
    }

Usage Example

Пример #1
0
 protected function beforeLogout($identity)
 {
     $event_result = parent::beforeLogout($identity);
     // let a change to plugins to authorize or not this logon
     if ($this->getHook()->has_filter('cruge_beforelogout')) {
         return $this->getHook()->apply_filters('cruge_beforelogout', array($identity, $event_result));
     } else {
         return $event_result;
     }
     // no filters setted.
 }