mirror of
https://github.com/silverstripe/silverstripe-iframe
synced 2024-06-28 15:39:29 +02:00
30 lines
804 B
PHP
30 lines
804 B
PHP
<?php
|
|
|
|
namespace SilverStripe\IFrame;
|
|
|
|
use PageController;
|
|
use SilverStripe\Control\Director;
|
|
use SilverStripe\View\Requirements;
|
|
|
|
class IFramePageController extends PageController
|
|
{
|
|
protected function init()
|
|
{
|
|
parent::init();
|
|
$currentProtocol = Director::protocol();
|
|
$desiredProtocol = $this->ForceProtocol;
|
|
if ($desiredProtocol && $currentProtocol !== $desiredProtocol) {
|
|
$enforcedLocation = preg_replace(
|
|
"#^${currentProtocol}#",
|
|
$desiredProtocol ?? '',
|
|
$this->AbsoluteLink() ?? ''
|
|
);
|
|
return $this->redirect($enforcedLocation);
|
|
}
|
|
|
|
if ($this->IFrameURL) {
|
|
Requirements::javascript('silverstripe/iframe: javascript/iframe_page.js');
|
|
}
|
|
}
|
|
}
|