Completed
Push — master ( e0cd62...080a96 )
by Andrii
03:16
created

CommandController::actionBefore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * Task runner, code generator and build tool for easier continuos integration
5
 *
6
 * @link      https://github.com/hiqdev/hidev
7
 * @package   hidev
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hidev\controllers;
13
14
use Yii;
15
16
/**
17
 * Command controller.
18
 */
19
class CommandController extends CommonController
20
{
21
    public $path;
22
    public $sudo;
23
    public $command;
24
    public $comment;
25
26
    protected $_cwd;
27
28
    public function actionSave()
29
    {
30
        passthru(($this->sudo ? 'sudo ' : '') . $this->command);
31
    }
32
33
    public function actionBefore()
34
    {
35
        $this->_cwd = getcwd();
36
        chdir(Yii::getAlias($this->path));
37
        parent::actionBefore();
38
    }
39
40
    public function actionAfter()
41
    {
42
        parent::actionAfter();
43
        chdir($this->_cwd);
44
    }
45
}
46