Skip to content

Commit 9ec1760

Browse files
author
Bohdan Korablov
committed
MAGETWO-47054: BaseURL in Static View Files
1 parent 4d76c3e commit 9ec1760

File tree

5 files changed

+15
-43
lines changed

5 files changed

+15
-43
lines changed

app/code/Magento/Backend/view/adminhtml/templates/page/js/require_js.phtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
<script>
88
var BASE_URL = '<?php /* @escapeNotVerified */ echo $block->getUrl('*') ?>';
99
var FORM_KEY = '<?php /* @escapeNotVerified */ echo $block->getFormKey() ?>';
10+
var require = {
11+
"baseUrl": "<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('/') ?>"
12+
};
1013
</script>

app/code/Magento/RequireJs/Block/Html/Head/Config.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,4 @@ protected function _prepareLayout()
119119

120120
return parent::_prepareLayout();
121121
}
122-
123-
/**
124-
* Include base RequireJs configuration necessary for working with Magento application
125-
*
126-
* @return string|void
127-
*/
128-
protected function _toHtml()
129-
{
130-
return "<script type=\"text/javascript\">\n"
131-
. $this->config->getBaseConfig()
132-
. "</script>\n";
133-
}
134122
}

app/code/Magento/RequireJs/Test/Unit/Block/Html/Head/ConfigTest.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -131,35 +131,4 @@ public function testSetLayout()
131131
);
132132
$object->setLayout($layout);
133133
}
134-
135-
public function testToHtml()
136-
{
137-
$this->context->expects($this->once())
138-
->method('getEventManager')
139-
->will($this->returnValue($this->getMockForAbstractClass('\Magento\Framework\Event\ManagerInterface')));
140-
$this->context->expects($this->once())
141-
->method('getScopeConfig')
142-
->will($this->returnValue(
143-
$this->getMockForAbstractClass('\Magento\Framework\App\Config\ScopeConfigInterface')
144-
));
145-
$this->config->expects($this->once())->method('getBaseConfig')->will($this->returnValue('the config data'));
146-
$this->minificationMock = $this->getMockBuilder('Magento\Framework\View\Asset\Minification')
147-
->disableOriginalConstructor()
148-
->getMock();
149-
150-
$object = new Config(
151-
$this->context,
152-
$this->config,
153-
$this->fileManager,
154-
$this->pageConfig,
155-
$this->bundleConfig,
156-
$this->minificationMock
157-
);
158-
$html = $object->toHtml();
159-
$expectedFormat = <<<expected
160-
<script type="text/javascript">
161-
the config data</script>
162-
expected;
163-
$this->assertStringMatchesFormat($expectedFormat, $html);
164-
}
165134
}

app/code/Magento/Theme/view/frontend/layout/default.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<page layout="3columns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
99
<update handle="default_head_blocks"/>
1010
<body>
11+
<block name="require.js" class="Magento\Framework\View\Element\Template" template="Magento_Theme::page/js/require_js.phtml" />
1112
<referenceContainer name="after.body.start">
1213
<block class="Magento\RequireJs\Block\Html\Head\Config" name="requirejs-config"/>
1314
<block class="Magento\Translation\Block\Html\Head\Config" name="translate-config"/>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
?>
7+
<script>
8+
var require = {
9+
"baseUrl": "<?php /* @escapeNotVerified */ echo $block->getViewFileUrl('/') ?>"
10+
};
11+
</script>

0 commit comments

Comments
 (0)