ViewLogAction::run()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 5
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 10
ccs 0
cts 8
cp 0
crap 12
rs 10
1
<?php
2
/**
3
 * @copyright Copyright(c) 2016 Webtools Ltd
4
 * @copyright Copyright(c) 2018 Thamtech, LLC
5
 * @link https://github.com/thamtech/yii2-scheduler
6
 * @license https://opensource.org/licenses/MIT
7
**/
8
9
namespace thamtech\scheduler\actions;
10
11
use Yii;
12
use yii\base\Action;
13
use thamtech\scheduler\models\SchedulerLog;
14
15
/**
16
 * View a log entry.
17
 */
18
class ViewLogAction extends Action
19
{
20
    /**
21
     * @var string the view file to be rendered. If not set, it will take the value of [[id]].
22
     * That means, if you name the action as "index" in "SchedulerController", then the view name
23
     * would be "index", and the corresponding view file would be "views/scheduler/index.php".
24
     */
25
    public $view;
26
27
    /**
28
     * Runs the action
29
     *
30
     * @return string result content
31
     */
32
    public function run($id)
33
    {
34
        $model = SchedulerLog::findOne($id);
35
36
        if (!$model) {
0 ignored issues
show
introduced by
$model is of type yii\db\ActiveRecord, thus it always evaluated to true.
Loading history...
37
            throw new \yii\web\HttpException(404, 'The requested page does not exist.');
38
        }
39
40
        return $this->controller->render($this->view ?: $this->id, [
41
            'model' => $model,
42
        ]);
43
    }
44
}
45