DevBuildController::build()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 1
dl 0
loc 18
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\Dev;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Control\Director;
7
use SilverStripe\ORM\DatabaseAdmin;
8
9
class DevBuildController extends Controller
10
{
11
12
    private static $url_handlers = array(
0 ignored issues
show
introduced by
The private property $url_handlers is not used, and could be removed.
Loading history...
13
        '' => 'build'
14
    );
15
16
    private static $allowed_actions = array(
0 ignored issues
show
introduced by
The private property $allowed_actions is not used, and could be removed.
Loading history...
17
        'build'
18
    );
19
20
    public function build($request)
21
    {
22
        if (Director::is_cli()) {
23
            $da = DatabaseAdmin::create();
24
            return $da->handleRequest($request);
25
        } else {
26
            $renderer = DebugView::create();
27
            echo $renderer->renderHeader();
28
            echo $renderer->renderInfo("Environment Builder", Director::absoluteBaseURL());
29
            echo "<div class=\"build\">";
30
31
            $da = DatabaseAdmin::create();
32
            $response = $da->handleRequest($request);
33
34
            echo "</div>";
35
            echo $renderer->renderFooter();
36
37
            return $response;
38
        }
39
    }
40
}
41