Issues (10)

src/Control/LeftAndMainDarkThemeToggle.php (4 issues)

1
<?php
2
3
namespace Sunnysideup\CMSDarkTheme\Control;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Control\HTTPRequest;
7
use SilverStripe\Control\HTTPResponse;
8
use Sunnysideup\CMSDarkTheme\Api\LeftAndMainDarkThemeApi;
9
10
/**
11
 * Class \Sunnysideup\CMSDarkTheme\Control\LeftAndMainDarkThemeToggle
12
 *
13
 */
14
class LeftAndMainDarkThemeToggle extends Controller
15
{
16
    private static $url_segment = 'admin/displaymode';
17
18
    private static $url_rule = '/$Action/$ID/$OtherID';
19
20
    // private static $ignore_menuitem = false;
21
22
    private static $allowed_actions = [
23
        'switch',
24
        'setlightmode',
25
        'setdarkmode',
26
    ];
27
28
    /**
29
     * set mode and then.
30
     *
31
     * @param HTTPRequest $request
32
     *
33
     * @return HTTPResponse
34
     */
35
    public function index($request)
36
    {
37
        return $this->switch($request);
38
    }
39
40
    /**
41
     * set mode and then.
42
     *
43
     * @param HTTPRequest $request
44
     *
45
     * @return HTTPResponse
46
     */
47
    public function switch($request)
0 ignored issues
show
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

47
    public function switch(/** @scrutinizer ignore-unused */ $request)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
    {
49
        $owner = $this->getOwner();
0 ignored issues
show
The method getOwner() does not exist on Sunnysideup\CMSDarkTheme...tAndMainDarkThemeToggle. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        /** @scrutinizer ignore-call */ 
50
        $owner = $this->getOwner();
Loading history...
50
        if (LeftAndMainDarkThemeApi::is_dark_mode()) {
51
            LeftAndMainDarkThemeApi::set_display_mode('Light');
52
        } else {
53
            LeftAndMainDarkThemeApi::set_display_mode('Dark');
54
        }
55
56
        return $owner->redirect('/admin/myprofile#Root_Cms');
57
    }
58
59
    public function setlightmode($request): HTTPResponse
0 ignored issues
show
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

59
    public function setlightmode(/** @scrutinizer ignore-unused */ $request): HTTPResponse

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
60
    {
61
        $owner = $this->getOwner();
62
        LeftAndMainDarkThemeApi::set_display_mode('Light');
63
64
        return $owner->redirect('admin/myprofile#Root_Cms');
65
    }
66
67
    public function setdarkmode($request): HTTPResponse
0 ignored issues
show
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

67
    public function setdarkmode(/** @scrutinizer ignore-unused */ $request): HTTPResponse

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
68
    {
69
        $owner = $this->getOwner();
70
        LeftAndMainDarkThemeApi::set_display_mode('Dark');
71
72
        return $owner->redirect('admin/myprofile#Root_Cms');
73
    }
74
}
75