Passed
Push — master ( abb7a8...4d3a01 )
by Mihail
03:55
created

Main::actionInstall()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 16
rs 9.2
cc 4
eloc 9
nc 3
nop 0
1
<?php
2
3
namespace Apps\Controller\Install;
4
5
6
use Apps\Model\Install\Main\EntityCheck;
7
use Apps\Model\Install\Main\FormInstall;
8
use Ffcms\Core\App;
9
use Ffcms\Core\Arch\Controller;
10
use Ffcms\Core\Exception\ForbiddenException;
11
use Ffcms\Core\Exception\NativeException;
12
use Ffcms\Core\Helper\FileSystem\File;
13
14
class Main extends Controller
15
{
16
17
    public function before()
18
    {
19
        if (File::exist('/Private/Install/final.lock')) {
20
            throw new NativeException('Page is not founded!');
21
        }
22
    }
23
24
    /**
25
     * Show environment check form
26
     * @throws ForbiddenException
27
     * @throws \Ffcms\Core\Exception\SyntaxException
28
     */
29
    public function actionIndex()
30
    {
31
        if (File::exist('/Private/Install/install.lock')) {
32
            throw new ForbiddenException('Installer is blocked! If you want to continue delete file /Private/Installer/install.lock');
33
        }
34
35
        $model = new EntityCheck();
36
37
        $this->response = App::$View->render('index', [
38
            'model' => $model
39
        ]);
40
    }
41
42
    /**
43
     * Installation form
44
     * @throws ForbiddenException
45
     * @throws \Ffcms\Core\Exception\SyntaxException
46
     */
47
    public function actionInstall()
48
    {
49
        if (File::exist('/Private/Install/install.lock')) {
50
            throw new ForbiddenException('Installer is blocked! If you want to continue delete file /Private/Installer/install.lock');
51
        }
52
53
        $model = new FormInstall();
54
        if ($model->send() && $model->validate()) {
55
            $model->make();
56
            App::$Response->redirect('main/success');
57
        }
58
59
        $this->response = App::$View->render('install', [
60
            'model' => $model->export()
61
        ]);
62
    }
63
64
    /**
65
     * Display view of success process finish
66
     * @throws \Ffcms\Core\Exception\SyntaxException
67
     */
68
    public function actionSuccess()
69
    {
70
        $this->response = App::$View->render('success');
71
    }
72
}