Passed
Push — master ( 57f692...abb7a8 )
by Mihail
04:20
created

Main   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
c 1
b 1
f 0
lcom 1
cbo 8
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A actionIndex() 0 12 2
A actionInstall() 0 16 4
A actionSuccess() 0 4 1
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\Helper\FileSystem\File;
12
13
class Main extends Controller
14
{
15
16
    public function actionIndex()
17
    {
18
        if (File::exist('/Private/Install/install.lock')) {
19
            throw new ForbiddenException('Installer is blocked! If you want to continue delete file /Private/Installer/install.lock');
20
        }
21
22
        $model = new EntityCheck();
23
24
        $this->response = App::$View->render('index', [
25
            'model' => $model
26
        ]);
27
    }
28
29
    public function actionInstall()
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 FormInstall();
36
        if ($model->send() && $model->validate()) {
37
            $model->make();
38
            App::$Response->redirect('main/success');
39
        }
40
41
        $this->response = App::$View->render('install', [
42
            'model' => $model->export()
43
        ]);
44
    }
45
46
    public function actionSuccess()
47
    {
48
        $this->response = App::$View->render('success');
49
    }
50
}