SapphireInfo::EnvironmentType()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 0
dl 0
loc 8
rs 10
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\Security\Permission;
8
use SilverStripe\Security\Security;
9
10
/**
11
 * Returns information about the current site instance.
12
 */
13
class SapphireInfo extends Controller
14
{
15
    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...
16
        'baseurl',
17
        'version',
18
        'environmenttype',
19
    );
20
21
    protected function init()
22
    {
23
        parent::init();
24
        if (!Director::is_cli() && !Permission::check('ADMIN')) {
25
            Security::permissionFailure();
26
        }
27
    }
28
29
    public function Version()
30
    {
31
        $sapphireVersion = file_get_contents(FRAMEWORK_PATH . '/silverstripe_version');
32
        if (!$sapphireVersion) {
33
            $sapphireVersion = _t('SilverStripe\\Admin\\LeftAndMain.VersionUnknown', 'unknown');
34
        }
35
        return $sapphireVersion;
36
    }
37
38
    public function EnvironmentType()
39
    {
40
        if (Director::isLive()) {
41
            return "live";
42
        } elseif (Director::isTest()) {
43
            return "test";
44
        } else {
45
            return "dev";
46
        }
47
    }
48
49
    public function BaseURL()
50
    {
51
        return Director::absoluteBaseURL();
52
    }
53
}
54