Skip to content

Commit de3b6e2

Browse files
author
Dale Sikkema
committed
MAGETWO-33609: pull request for stories in this sprint
- move store config xml path constants to Store model
1 parent d577626 commit de3b6e2

File tree

15 files changed

+56
-47
lines changed

15 files changed

+56
-47
lines changed

app/code/Magento/AdminNotification/Model/System/Message/Baseurl.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magento\AdminNotification\Model\System\Message;
1010

1111
use Magento\Framework\Store\StoreManagerInterface;
12+
use Magento\Store\Model\Store;
1213

1314
class Baseurl implements \Magento\Framework\Notification\MessageInterface
1415
{
@@ -58,9 +59,9 @@ public function __construct(
5859
protected function _getConfigUrl()
5960
{
6061
$output = '';
61-
$defaultUnsecure = $this->_config->getValue(StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL, 'default');
62+
$defaultUnsecure = $this->_config->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
6263

63-
$defaultSecure = $this->_config->getValue(StoreManagerInterface::XML_PATH_SECURE_BASE_URL, 'default');
64+
$defaultSecure = $this->_config->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default');
6465

6566
if ($defaultSecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER ||
6667
$defaultUnsecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER

app/code/Magento/AdminNotification/Model/System/Message/Security.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
namespace Magento\AdminNotification\Model\System\Message;
1010

1111
use Magento\Framework\Store\StoreManagerInterface;
12+
use Magento\Store\Model\Store;
1213

1314
class Security implements \Magento\Framework\Notification\MessageInterface
1415
{
@@ -95,7 +96,7 @@ private function _canShowNotification()
9596
*/
9697
private function _isFileAccessible()
9798
{
98-
$unsecureBaseURL = $this->_config->getValue(StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL, 'default');
99+
$unsecureBaseURL = $this->_config->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default');
99100

100101
/** @var $http \Magento\Framework\HTTP\Adapter\Curl */
101102
$http = $this->_curlFactory->create();

app/code/Magento/Backend/Model/Config/Backend/Baseurl.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Backend\Model\Config\Backend;
77

88
use Magento\Framework\Store\StoreManagerInterface;
9+
use Magento\Store\Model\Store;
910

1011
class Baseurl extends \Magento\Framework\App\Config\Value
1112
{
@@ -68,7 +69,7 @@ private function _validateUnsecure($value)
6869
{
6970
$placeholders = ['{{unsecure_base_url}}'];
7071
switch ($this->getPath()) {
71-
case StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL:
72+
case Store::XML_PATH_UNSECURE_BASE_URL:
7273
$this->_assertValuesOrUrl(['{{base_url}}'], $value);
7374
break;
7475
case \Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL:
@@ -94,7 +95,7 @@ private function _validateSecure($value)
9495
{
9596
$placeholders = ['{{unsecure_base_url}}', '{{secure_base_url}}'];
9697
switch ($this->getPath()) {
97-
case StoreManagerInterface::XML_PATH_SECURE_BASE_URL:
98+
case Store::XML_PATH_SECURE_BASE_URL:
9899
$this->_assertValuesOrUrl(['{{base_url}}', '{{unsecure_base_url}}'], $value);
99100
break;
100101
case \Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL:
@@ -206,9 +207,9 @@ public function afterSave()
206207
{
207208
if ($this->isValueChanged()) {
208209
switch ($this->getPath()) {
209-
case StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL:
210+
case Store::XML_PATH_UNSECURE_BASE_URL:
210211
case \Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL:
211-
case StoreManagerInterface::XML_PATH_SECURE_BASE_URL:
212+
case Store::XML_PATH_SECURE_BASE_URL:
212213
case \Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL:
213214
$this->_mergeService->cleanMergedJsCss();
214215
break;

app/code/Magento/Email/Model/Source/Variables.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Email\Model\Source;
77

88
use Magento\Framework\Store\StoreManagerInterface;
9+
use Magento\Store\Model\Store;
910

1011
/**
1112
* Store Contact Information source model
@@ -28,10 +29,10 @@ public function __construct()
2829
{
2930
$this->_configVariables = [
3031
[
31-
'value' => StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL,
32+
'value' => Store::XML_PATH_UNSECURE_BASE_URL,
3233
'label' => __('Base Unsecure URL'),
3334
],
34-
['value' => StoreManagerInterface::XML_PATH_SECURE_BASE_URL, 'label' => __('Base Secure URL')],
35+
['value' => Store::XML_PATH_SECURE_BASE_URL, 'label' => __('Base Secure URL')],
3536
['value' => 'trans_email/ident_general/name', 'label' => __('General Contact Name')],
3637
['value' => 'trans_email/ident_general/email', 'label' => __('General Contact Email')],
3738
['value' => 'trans_email/ident_sales/name', 'label' => __('Sales Representative Contact Name')],

app/code/Magento/Store/Helper/SecureUrl.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Framework\Store\StoreManagerInterface;
99
use Magento\Framework\Store\ScopeInterface;
10+
use Magento\Store\Model\Store;
1011

1112
class SecureUrl implements \Magento\Framework\App\Router\SecureUrlInterface
1213
{
@@ -59,17 +60,17 @@ public function shouldBeSecure($path)
5960
{
6061
return parse_url(
6162
$this->scopeConfig->getValue(
62-
StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL,
63+
Store::XML_PATH_UNSECURE_BASE_URL,
6364
ScopeInterface::SCOPE_STORE
6465
),
6566
PHP_URL_SCHEME
6667
) === 'https'
6768
|| $this->scopeConfig->isSetFlag(
68-
StoreManagerInterface::XML_PATH_SECURE_IN_FRONTEND,
69+
Store::XML_PATH_SECURE_IN_FRONTEND,
6970
ScopeInterface::SCOPE_STORE
7071
) && parse_url(
7172
$this->scopeConfig->getValue(
72-
StoreManagerInterface::XML_PATH_SECURE_BASE_URL,
73+
Store::XML_PATH_SECURE_BASE_URL,
7374
ScopeInterface::SCOPE_STORE
7475
),
7576
PHP_URL_SCHEME

app/code/Magento/Store/Model/Store.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ class Store extends AbstractModel implements
5252

5353
const XML_PATH_USE_REWRITES = 'web/seo/use_rewrites';
5454

55+
const XML_PATH_UNSECURE_BASE_URL = 'web/unsecure/base_url';
56+
57+
const XML_PATH_SECURE_BASE_URL = 'web/secure/base_url';
58+
59+
const XML_PATH_SECURE_IN_FRONTEND = 'web/secure/use_in_frontend';
60+
5561
const XML_PATH_SECURE_IN_ADMINHTML = 'web/secure/use_in_adminhtml';
5662

5763
const XML_PATH_SECURE_BASE_LINK_URL = 'web/secure/base_link_url';
@@ -538,8 +544,8 @@ public function getBaseUrl($type = \Magento\Framework\UrlInterface::URL_TYPE_LIN
538544
switch ($type) {
539545
case \Magento\Framework\UrlInterface::URL_TYPE_WEB:
540546
$path = $secure
541-
? StoreManagerInterface::XML_PATH_SECURE_BASE_URL
542-
: StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL;
547+
? self::XML_PATH_SECURE_BASE_URL
548+
: self::XML_PATH_UNSECURE_BASE_URL;
543549
$url = $this->_getConfig($path);
544550
break;
545551

@@ -717,7 +723,7 @@ public function isFrontUrlSecure()
717723
{
718724
if ($this->_isFrontSecure === null) {
719725
$this->_isFrontSecure = $this->_config->isSetFlag(
720-
StoreManagerInterface::XML_PATH_SECURE_IN_FRONTEND,
726+
self::XML_PATH_SECURE_IN_FRONTEND,
721727
\Magento\Framework\Store\ScopeInterface::SCOPE_STORE,
722728
$this->getId()
723729
);
@@ -745,7 +751,7 @@ public function isCurrentlySecure()
745751
}
746752

747753
$secureBaseUrl = $this->_config->getValue(
748-
StoreManagerInterface::XML_PATH_SECURE_BASE_URL,
754+
self::XML_PATH_SECURE_BASE_URL,
749755
\Magento\Framework\Store\ScopeInterface::SCOPE_STORE
750756
);
751757

dev/tests/integration/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Backend\Model\Config\Backend;
77

88
use Magento\Framework\Store\StoreManagerInterface;
9+
use Magento\Store\Model\Store;
910

1011
/**
1112
* @magentoAppArea adminhtml
@@ -42,7 +43,7 @@ public function validationDataProvider()
4243
return [
4344
['any/path', 'http://example.com/'],
4445
['any/path', 'http://example.com/uri/'],
45-
[StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL, $basePlaceholder],
46+
[Store::XML_PATH_UNSECURE_BASE_URL, $basePlaceholder],
4647
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, $unsecurePlaceholder],
4748
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, $unsecureSuffix],
4849
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_STATIC_URL, ''],
@@ -51,7 +52,7 @@ public function validationDataProvider()
5152
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL, ''],
5253
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL, $unsecurePlaceholder],
5354
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL, $unsecureSuffix],
54-
[StoreManagerInterface::XML_PATH_SECURE_BASE_URL, $basePlaceholder],
55+
[Store::XML_PATH_SECURE_BASE_URL, $basePlaceholder],
5556
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $securePlaceholder],
5657
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $secureSuffix],
5758
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, ''],
@@ -60,7 +61,7 @@ public function validationDataProvider()
6061
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, ''],
6162
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, $securePlaceholder],
6263
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_MEDIA_URL, $secureSuffix],
63-
[StoreManagerInterface::XML_PATH_SECURE_BASE_URL, $unsecurePlaceholder],
64+
[Store::XML_PATH_SECURE_BASE_URL, $unsecurePlaceholder],
6465
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $unsecurePlaceholder],
6566
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $unsecureSuffix],
6667
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_STATIC_URL, ''],
@@ -106,19 +107,19 @@ public function validationExceptionDataProvider()
106107
['', 'example.com'],
107108
['', 'http://example.com'],
108109
['', 'http://example.com/uri'],
109-
[StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL, ''],
110-
[StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL, $baseSuffix],
111-
[StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL, $unsecureSuffix],
112-
[StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL, $unsecurePlaceholder],
110+
[Store::XML_PATH_UNSECURE_BASE_URL, ''],
111+
[Store::XML_PATH_UNSECURE_BASE_URL, $baseSuffix],
112+
[Store::XML_PATH_UNSECURE_BASE_URL, $unsecureSuffix],
113+
[Store::XML_PATH_UNSECURE_BASE_URL, $unsecurePlaceholder],
113114
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, ''],
114115
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, $baseSuffix],
115116
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_LINK_URL, $unsecureWrongSuffix],
116117
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_MEDIA_URL, $unsecureWrongSuffix],
117118
[\Magento\Store\Model\Store::XML_PATH_UNSECURE_BASE_STATIC_URL, $unsecureWrongSuffix],
118-
[StoreManagerInterface::XML_PATH_SECURE_BASE_URL, ''],
119-
[StoreManagerInterface::XML_PATH_SECURE_BASE_URL, $baseSuffix],
120-
[StoreManagerInterface::XML_PATH_SECURE_BASE_URL, $secureSuffix],
121-
[StoreManagerInterface::XML_PATH_SECURE_BASE_URL, $securePlaceholder],
119+
[Store::XML_PATH_SECURE_BASE_URL, ''],
120+
[Store::XML_PATH_SECURE_BASE_URL, $baseSuffix],
121+
[Store::XML_PATH_SECURE_BASE_URL, $secureSuffix],
122+
[Store::XML_PATH_SECURE_BASE_URL, $securePlaceholder],
122123
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, ''],
123124
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $baseSuffix],
124125
[\Magento\Store\Model\Store::XML_PATH_SECURE_BASE_LINK_URL, $secureWrongSuffix],

dev/tests/unit/testsuite/Magento/AdminNotification/Model/System/Message/BaseurlTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\AdminNotification\Model\System\Message;
77

88
use Magento\Framework\Store\StoreManagerInterface;
9+
use Magento\Store\Model\Store;
910

1011
class BaseurlTest extends \PHPUnit_Framework_TestCase
1112
{
@@ -113,13 +114,13 @@ public function testgetValueUrlWithDefaultUnsecureAndSecureBaseUrl()
113114
{
114115
$map = [
115116
[
116-
StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL,
117+
Store::XML_PATH_UNSECURE_BASE_URL,
117118
'default',
118119
null,
119120
\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER,
120121
],
121122
[
122-
StoreManagerInterface::XML_PATH_SECURE_BASE_URL,
123+
Store::XML_PATH_SECURE_BASE_URL,
123124
'default',
124125
null,
125126
\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER

dev/tests/unit/testsuite/Magento/Backend/Model/Config/Backend/BaseurlTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Backend\Model\Config\Backend;
77

88
use Magento\Framework\Store\StoreManagerInterface;
9+
use Magento\Store\Model\Store;
910

1011
class BaseurlTest extends \PHPUnit_Framework_TestCase
1112
{
@@ -45,7 +46,7 @@ public function testSaveMergedJsCssMustBeCleaned()
4546
);
4647
$mergeService->expects($this->once())->method('cleanMergedJsCss');
4748

48-
$model->setValue('http://example.com/')->setPath(StoreManagerInterface::XML_PATH_UNSECURE_BASE_URL);
49+
$model->setValue('http://example.com/')->setPath(Store::XML_PATH_UNSECURE_BASE_URL);
4950
$model->afterSave();
5051
}
5152
}

dev/tests/unit/testsuite/Magento/Setup/Model/UserConfigurationDataMapperTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Directory\Model\Currency;
1212
use Magento\Setup\Module\Setup;
1313
use Magento\Store\Model\Store;
14+
use Magento\Store\Model\StoreManager;
1415

1516
class UserConfigurationDataMapperTest extends \PHPUnit_Framework_TestCase
1617
{
@@ -26,7 +27,7 @@ public function testGetConfigData(array $data, array $expected)
2627
}
2728

2829
/**
29-
* return array
30+
* @return array
3031
*
3132
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
3233
*/

0 commit comments

Comments
 (0)