EnvBarLeftAndMainExtension::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
rs 10
1
<?php
2
3
namespace Signify\EnvBar\Extensions;
4
5
use SilverStripe\Control\Director;
6
use SilverStripe\Core\Extension;
7
use SilverStripe\View\Requirements;
8
9
/**
10
 * EnvBarLeftAndMainExtension
11
 *
12
 * This class extends the @see SilverStripe\Admin\LeftAndMain class.
13
 *
14
 * It inserts a custom div above the menu header the CMS Admin interface during
15
 * the init method via the css and javascript requirements.
16
 *
17
 * It uses the javascriptTemplate requirement so the environment type can be
18
 * passed in to the jQuery function for display.
19
 *
20
 * @package Signify\EnvBar\Extensions
21
 * @author Lani Field <[email protected]>
22
 * @version 1.0.0
23
 */
24
class EnvBarLeftAndMainExtension extends Extension
25
{
26
    public function init()
27
    {
28
        Requirements::css('signify-nz/silverstripe-environmentindicator:admin/client/dist/css/envbar.css');
29
30
        $vars = [
31
            'EnvType' => Director::get_environment_type(),
32
        ];
33
        Requirements::javascriptTemplate(
34
            'signify-nz/silverstripe-environmentindicator:admin/client/dist/js/envbar.js',
35
            $vars
36
        );
37
    }
38
}
39