Passed
Push — master ( 36d94c...6f4de6 )
by Sathish
01:39
created

ViewableuserInfoExtension   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 27
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 html
0 ignored issues
show
Bug introduced by
The type UserManagement\Extension\html was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
     */
24
    public static function getlogoutLink()
25
    {
26
        if (Security::getCurrentUser()) {
27
            $html = DBHTMLText::create();
28
            $html->setValue("<a href='" . Security::logout_url() . "&BackURL=/'>Logout</a>");
29
            return $html;
30
        }
31
        return false;
0 ignored issues
show
Bug Best Practice introduced by
The expression return false returns the type false which is incompatible with the documented return type UserManagement\Extension\html.
Loading history...
32
    }
33
34
    /**
35
     * Defines global accessible templates variables.
36
     *
37
     * @return array
38
     */
39
    public static function get_template_global_variables()
40
    {
41
        return [
42
            "LoginLink" => "getlogoutLink",
43
        ];
44
    }
45
}
46