Completed
Pull Request — master (#2)
by zacksleo
01:13
created

OauthClientsDeleteBehavior::afterDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 2
1
<?php
2
3
namespace zacksleo\yii2\oauth2\common\behaviors;
4
5
use zacksleo\yii2\oauth2\common\predis\Predis;
6
use common\models\OauthClients;
7
use filsh\yii2\oauth2server\models\OauthAuthorizationCodes;
8
use filsh\yii2\oauth2server\models\OauthRefreshTokens;
9
use yii\base\Behavior;
10
use yii\db\ActiveRecord;
11
12
class OauthClientsDeleteBehavior extends Behavior
13
{
14 4
    public function events()
15
    {
16
        return [
17 4
            ActiveRecord::EVENT_AFTER_DELETE => 'afterDelete'
18
        ];
19
    }
20
21
    public function afterDelete($event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23
        /* @var $model OauthClients */
24
        $model = $this->owner;
25
        //删除缓存
26
        Predis::getInstance()->getClient()->deleteClientToken($model->client_id);
27
        //删除Token
28
        //OauthAccessTokens::deleteAll(['client_id' => $model->client_id]);
29
        //删除授权码
30
        OauthAuthorizationCodes::deleteAll(['client_id' => $model->client_id]);
31
        //删除刷新Token
32
        OauthRefreshTokens::deleteAll(['client_id' => $model->client_id]);
33
    }
34
}
35