Completed
Push — master ( 6db6da...5370d9 )
by Angel
03:42
created

ProfileResource::verbs()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace roaresearch\yii2\roa\controllers;
4
5
use roaresearch\yii2\roa\actions\{ProfileUpdate, ProfileView};
6
use yii\{filters\VerbFilter, rest\OptionsAction};
7
8
class ProfileResource extends \yii\rest\Controller
9
{
10
    /**
11
     * @inheritdoc
12
     */
13
    public function behaviors()
14
    {
15
        return [
16
            // content negotiator, autenticator, etc moved by default to
17
            // api container
18
            'verbFilter' => [
19
                'class' => VerbFilter::class,
20
                'actions' => $this->verbs(),
21
            ],
22
        ];
23
    }
24
25
    /**
26
     * @inheridoc
27
     */
28
    protected function verbs()
29
    {
30
        $verbs = ['GET', 'PUT', 'PATCH', 'OPTIONS'];
31
32
        return [
33
            'view' => $verbs,
34
            'update' => $verbs,
35
            'options' => $verbs,
36
        ];
37
    }
38
39
    /**
40
     * @inheridoc
41
     */
42
    public function actions()
43
    {
44
        return [
45
            'view' => ['class' => ProfileView::class],
46
            'update' => ['class' => ProfileUpdate::class],
47
            'options' => ['class' => OptionsAction::class],
48
        ];
49
    }
50
}
51