mirror of
https://github.com/silverstripe/silverstripe-iframe
synced 2024-10-22 11:05:51 +02:00
FIX: Use new resource loading syntax for javascript
SilverStripe 4 vendormodule types make use of an 'expose' composer directive to allow assets they provide to be accessed by a web request. Previously the javascript for the iFrame resizing business tried to load from a static path that no longer exists (referenced inside PHP), which caused a fatal error. This has been fixed along with making the conditional code for enforcing a protocol on the page's request a bit more readable & easily digestable to developers.
This commit is contained in:
parent
e394d9098c
commit
4fb947d0c7
@ -11,17 +11,19 @@ class IFramePageController extends ContentController
|
|||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
parent::init();
|
parent::init();
|
||||||
|
$currentProtocol = Director::protocol();
|
||||||
if ($this->ForceProtocol) {
|
$desiredProtocol = $this->ForceProtocol;
|
||||||
if ($this->ForceProtocol == 'http://' && Director::protocol() != 'http://') {
|
if ($desiredProtocol && $currentProtocol !== $desiredProtocol) {
|
||||||
return $this->redirect(preg_replace('#https://#', 'http://', $this->AbsoluteLink()));
|
$enforcedLocation = preg_replace(
|
||||||
} elseif ($this->ForceProtocol == 'https://' && Director::protocol() != 'https://') {
|
"#^${currentProtocol}#",
|
||||||
return $this->redirect(preg_replace('#http://#', 'https://', $this->AbsoluteLink()));
|
$desiredProtocol,
|
||||||
}
|
$this->AbsoluteLink()
|
||||||
|
);
|
||||||
|
return $this->redirect($enforcedLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->IFrameURL) {
|
if ($this->IFrameURL) {
|
||||||
Requirements::javascript('iframe/javascript/iframe_page.js');
|
Requirements::javascript('silverstripe/iframe: javascript/iframe_page.js');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user