Issues (2882)

src/Dev/SapphireInfo.php (1 issue)

Severity
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
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