Passed
Pull Request — master (#432)
by Alexander
02:41
created

DefaultController::behaviors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace mdm\admin\controllers;
4
5
use Yii;
6
use mdm\admin\components\AccessControl;
7
8
/**
9
 * DefaultController
10
 *
11
 * @author Misbahul D Munir <[email protected]>
12
 * @since 1.0
13
 */
14
class DefaultController extends \yii\web\Controller
15
{
16
17
    /**
18
     * @inheritdoc
19
     */
20
    public function behaviors()
21
    {
22
        return [
23
            'access' => [
24
                'class' => AccessControl::class,
25
            ],
26
        ];
27
    }
28
29
    /**
30
     * Action index
31
     */
32
    public function actionIndex($page = 'README.md')
33
    {
34
        if (strpos($page, '.png') !== false) {
35
            $file = Yii::getAlias("@mdm/admin/{$page}");
36
            return Yii::$app->getResponse()->sendFile($file);
37
        }
38
        return $this->render('index', ['page' => $page]);
39
    }
40
}
41