Completed
Push — master ( eb7aa9...68c092 )
by zacksleo
02:38 queued 01:19
created

OauthClientsDeleteBehavior::afterDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 13
ccs 6
cts 6
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
3
namespace zacksleo\yii2\oauth2\common\behaviors;
4
5
use zacksleo\yii2\oauth2\common\helpers\Predis;
6
use zacksleo\yii2\oauth2\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 7
    public function events()
15
    {
16
        return [
17 7
            ActiveRecord::EVENT_AFTER_DELETE => 'afterDelete'
18
        ];
19
    }
20
21 1
    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 1
        $model = $this->owner;
25
        //删除缓存
26 1
        Predis::getInstance()->getClient()->deleteClientToken($model->client_id);
27
        //删除Token
28
        //OauthAccessTokens::deleteAll(['client_id' => $model->client_id]);
29
        //删除授权码
30 1
        OauthAuthorizationCodes::deleteAll(['client_id' => $model->client_id]);
31
        //删除刷新Token
32 1
        OauthRefreshTokens::deleteAll(['client_id' => $model->client_id]);
33 1
    }
34
}
35