Passed
Pull Request — master (#3)
by Angel
04:19
created

WorkflowResource::actions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
ccs 4
cts 4
cp 1
crap 1
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace roaresearch\yii2\workflow\roa\resources;
4
5
use roaresearch\yii2\roa\{actions\SoftDelete, controllers\Resource};
6
use roaresearch\yii2\workflow\roa\models\{Workflow, WorkflowSearch};
7
use yii\db\ActiveQuery;
8
9
/**
10
 * Resource to handle `Workflow` records
11
 *
12
 * @author Angel (Faryshta) Guevara <[email protected]>
13
 */
14
class WorkflowResource extends Resource
15
{
16
    /**
17
     * @inheritdoc
18
     */
19
    public $modelClass = Workflow::class;
20
21
    /**
22
     * @inheritdoc
23
     */
24
    public $searchClass = WorkflowSearch::class;
25
26
    /**
27
     * @inheritdoc
28
     */
29 5
    public function actions()
30
    {
31 5
        $actions = parent::actions();
32 5
        $actions['delete']['class'] = SoftDelete::class;
33
34 5
        return $actions;
35
    }
36
37
    /**
38
     * @inheritdoc
39
     */
40 3
    public function baseQuery(): ActiveQuery
41
    {
42 3
        return parent::baseQuery()
43 3
            ->andWhere(['deleted_at' => null, 'deleted_by' => null]);
44
    }
45
}
46