Completed
Push — master ( df6bd2...c3da4e )
by Robbie
12s
created

IFramePageController::init()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 11
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 16
rs 9.2
1
<?php
2
3
namespace SilverStripe\IFrame;
4
5
use SilverStripe\CMS\Controllers\ContentController;
6
use SilverStripe\Control\Director;
7
use SilverStripe\View\Requirements;
8
9
class IFramePageController extends ContentController
10
{
11
    protected function init()
12
    {
13
        parent::init();
14
        $currentProtocol = Director::protocol();
15
        $desiredProtocol = $this->ForceProtocol;
0 ignored issues
show
Bug Best Practice introduced by
The property ForceProtocol does not exist on SilverStripe\IFrame\IFramePageController. Since you implemented __get, consider adding a @property annotation.
Loading history...
16
        if ($desiredProtocol && $currentProtocol !== $desiredProtocol) {
17
            $enforcedLocation = preg_replace(
18
                "#^${currentProtocol}#",
19
                $desiredProtocol,
20
                $this->AbsoluteLink()
0 ignored issues
show
Bug introduced by
The method AbsoluteLink() does not exist on SilverStripe\IFrame\IFramePageController. 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

20
                $this->/** @scrutinizer ignore-call */ 
21
                       AbsoluteLink()
Loading history...
21
            );
22
            return $this->redirect($enforcedLocation);
23
        }
24
25
        if ($this->IFrameURL) {
0 ignored issues
show
Bug Best Practice introduced by
The property IFrameURL does not exist on SilverStripe\IFrame\IFramePageController. Since you implemented __get, consider adding a @property annotation.
Loading history...
26
            Requirements::javascript('silverstripe/iframe: javascript/iframe_page.js');
27
        }
28
    }
29
}
30