ViewableuserInfoExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 27
ccs 5
cts 8
cp 0.625
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_template_global_variables() 0 4 1
A getlogoutLink() 0 8 2
1
<?php
2
namespace UserManagement\Extension;
3
4
use SilverStripe\Core\Extension;
5
use SilverStripe\Security\Group;
6
use SilverStripe\View\ViewableData;
7
use SilverStripe\Security\Security;
8
use SilverStripe\ORM\FieldType\DBHTMLText;
9
use SilverStripe\View\TemplateGlobalProvider;
10
11
/**
12
 * Class ViewableuserInfoExtension
13
 *
14
 * @package user-management
15
 */
16
class ViewableuserInfoExtension extends Extension implements TemplateGlobalProvider
17
{
18
19
    /**
20
     * Returns logout link
21
     *
22
     * @return string | bool
23
     */
24 1
    public static function getlogoutLink()
25
    {
26 1
        if (Security::getCurrentUser()) {
27
            $html = DBHTMLText::create();
28
            $html->setValue("<a href='" . Security::logout_url() . "&BackURL=/'>Logout</a>");
29
            return $html;
30
        }
31 1
        return false;
32
    }
33
34
    /**
35
     * Defines global accessible templates variables.
36
     *
37
     * @return array
38
     */
39 1
    public static function get_template_global_variables()
40
    {
41
        return [
42 1
            "LoginLink" => "getlogoutLink",
43
        ];
44
    }
45
}
46