IFramePageController   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 16 4
1
<?php
2
3
namespace SilverStripe\IFrame;
4
5
use PageController;
0 ignored issues
show
Bug introduced by
The type PageController 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...
6
use SilverStripe\Control\Director;
7
use SilverStripe\View\Requirements;
8
9
class IFramePageController extends PageController
10
{
11
    protected function init()
12
    {
13
        parent::init();
14
        $currentProtocol = Director::protocol();
15
        $desiredProtocol = $this->ForceProtocol;
16
        if ($desiredProtocol && $currentProtocol !== $desiredProtocol) {
17
            $enforcedLocation = preg_replace(
18
                "#^${currentProtocol}#",
19
                $desiredProtocol,
20
                $this->AbsoluteLink()
21
            );
22
            return $this->redirect($enforcedLocation);
23
        }
24
25
        if ($this->IFrameURL) {
26
            Requirements::javascript('silverstripe/iframe: javascript/iframe_page.js');
27
        }
28
    }
29
}
30