Skip to content

Commit 38360b5

Browse files
committed
Merge branch 'develop' of github.com:magento/magento2ce into troll_pr
2 parents 9952c02 + 3f4fe5e commit 38360b5

File tree

179 files changed

+6465
-1954
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

179 files changed

+6465
-1954
lines changed

app/code/Magento/Backend/App/Config.php

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,66 @@
1010

1111
namespace Magento\Backend\App;
1212

13+
use Magento\Config\App\Config\Type\System;
1314
use Magento\Framework\App\Config\ScopeConfigInterface;
1415

1516
/**
16-
* Backend config accessor
17+
* Backend config accessor.
1718
*/
1819
class Config implements ConfigInterface
1920
{
2021
/**
21-
* @var \Magento\Framework\App\Config\ScopePool
22+
* @var \Magento\Framework\App\Config
2223
*/
23-
protected $_scopePool;
24+
protected $appConfig;
2425

2526
/**
26-
* @param \Magento\Framework\App\Config\ScopePool $scopePool
27+
* @var array
2728
*/
28-
public function __construct(\Magento\Framework\App\Config\ScopePool $scopePool)
29+
private $data;
30+
31+
/**
32+
* @param \Magento\Framework\App\Config $appConfig
33+
* @return void
34+
*/
35+
public function __construct(\Magento\Framework\App\Config $appConfig)
2936
{
30-
$this->_scopePool = $scopePool;
37+
$this->appConfig = $appConfig;
3138
}
3239

3340
/**
34-
* Retrieve config value by path and scope
35-
*
36-
* @param string $path
37-
* @return mixed
41+
* @inheritdoc
3842
*/
3943
public function getValue($path)
4044
{
41-
return $this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
45+
if (isset($this->data[$path])) {
46+
return $this->data[$path];
47+
}
48+
49+
$configPath = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
50+
if ($path) {
51+
$configPath .= '/' . $path;
52+
}
53+
return $this->appConfig->get(System::CONFIG_TYPE, $configPath);
4254
}
4355

4456
/**
45-
* Set config value in the corresponding config scope
46-
*
47-
* @param string $path
48-
* @param mixed $value
49-
* @return void
57+
* @inheritdoc
5058
*/
5159
public function setValue($path, $value)
5260
{
53-
$this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->setValue($path, $value);
61+
$this->data[$path] = $value;
5462
}
5563

5664
/**
57-
* Retrieve config flag
58-
*
59-
* @param string $path
60-
* @return bool
65+
* @inheritdoc
6166
*/
6267
public function isSetFlag($path)
6368
{
64-
return !!$this->_scopePool->getScope(ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null)->getValue($path);
69+
$configPath = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
70+
if ($path) {
71+
$configPath .= '/' . $path;
72+
}
73+
return (bool) $this->appConfig->get(System::CONFIG_TYPE, $configPath);
6574
}
6675
}

app/code/Magento/Backend/App/ConfigInterface.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ interface ConfigInterface
1515
/**
1616
* Retrieve config value by path
1717
*
18+
* Path should looks like keys imploded by "/". For example scopes/stores/admin
19+
*
1820
* @param string $path
1921
* @return mixed
2022
* @api
@@ -24,6 +26,7 @@ public function getValue($path);
2426
/**
2527
* Set config value
2628
*
29+
* @deprecated
2730
* @param string $path
2831
* @param mixed $value
2932
* @return void
@@ -34,6 +37,8 @@ public function setValue($path, $value);
3437
/**
3538
* Retrieve config flag
3639
*
40+
* Path should looks like keys imploded by "/". For example scopes/stores/admin
41+
*
3742
* @param string $path
3843
* @return bool
3944
* @api

app/code/Magento/Backend/Test/Unit/App/ConfigTest.php

Lines changed: 31 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,18 @@
77

88
use Magento\Backend\App\Config;
99

10+
/**
11+
* Test reading by path and reading flag from config
12+
*
13+
* @see \Magento\Backend\App\Config
14+
* @package Magento\Backend\Test\Unit\App
15+
*/
1016
class ConfigTest extends \PHPUnit_Framework_TestCase
1117
{
1218
/**
13-
* @var \Magento\Framework\App\Config\ScopePool|\PHPUnit_Framework_MockObject_MockObject
19+
* @var \Magento\Framework\App\Config|\PHPUnit_Framework_MockObject_MockObject
1420
*/
15-
protected $sectionPool;
21+
protected $appConfig;
1622

1723
/**
1824
* @var Config
@@ -21,102 +27,64 @@ class ConfigTest extends \PHPUnit_Framework_TestCase
2127

2228
protected function setUp()
2329
{
24-
$this->sectionPool = $this->getMock(
25-
\Magento\Framework\App\Config\ScopePool::class,
26-
['getScope', 'clean'],
30+
$this->appConfig = $this->getMock(
31+
\Magento\Framework\App\Config::class,
32+
['get'],
2733
[],
2834
'',
2935
false
3036
);
31-
$this->model = new \Magento\Backend\App\Config($this->sectionPool);
37+
$this->model = new \Magento\Backend\App\Config($this->appConfig);
3238
}
3339

3440
public function testGetValue()
3541
{
3642
$expectedValue = 'some value';
3743
$path = 'some path';
38-
$configData = $this->getConfigDataMock('getValue');
39-
$configData->expects(
40-
$this->once()
41-
)->method(
42-
'getValue'
43-
)->with(
44-
$this->equalTo($path)
45-
)->will(
46-
$this->returnValue($expectedValue)
47-
);
48-
$this->sectionPool->expects(
44+
$this->appConfig->expects(
4945
$this->once()
5046
)->method(
51-
'getScope'
47+
'get'
5248
)->with(
53-
$this->equalTo('default'),
49+
$this->equalTo('system'),
50+
$this->equalTo('default/' . $path),
5451
$this->isNull()
5552
)->will(
56-
$this->returnValue($configData)
53+
$this->returnValue($expectedValue)
5754
);
5855
$this->assertEquals($expectedValue, $this->model->getValue($path));
5956
}
6057

61-
public function testSetValue()
62-
{
63-
$value = 'some value';
64-
$path = 'some path';
65-
$configData = $this->getConfigDataMock('setValue');
66-
$configData->expects($this->once())->method('setValue')->with($this->equalTo($path), $this->equalTo($value));
67-
$this->sectionPool->expects(
68-
$this->once()
69-
)->method(
70-
'getScope'
71-
)->with(
72-
$this->equalTo('default'),
73-
$this->isNull()
74-
)->will(
75-
$this->returnValue($configData)
76-
);
77-
$this->model->setValue($path, $value);
78-
}
79-
8058
/**
59+
* @param string $configPath
8160
* @param mixed $configValue
8261
* @param bool $expectedResult
8362
* @dataProvider isSetFlagDataProvider
8463
*/
85-
public function testIsSetFlag($configValue, $expectedResult)
64+
public function testIsSetFlag($configPath, $configValue, $expectedResult)
8665
{
87-
$path = 'some path';
88-
$configData = $this->getConfigDataMock('getValue');
89-
$configData->expects(
90-
$this->once()
66+
$this->appConfig->expects(
67+
$this->any()
9168
)->method(
92-
'getValue'
69+
'get'
9370
)->with(
94-
$this->equalTo($path)
71+
$this->equalTo('system'),
72+
$this->equalTo('default/' . $configPath)
9573
)->will(
9674
$this->returnValue($configValue)
9775
);
98-
$this->sectionPool->expects(
99-
$this->once()
100-
)->method(
101-
'getScope'
102-
)->with(
103-
$this->equalTo('default'),
104-
$this->isNull()
105-
)->will(
106-
$this->returnValue($configData)
107-
);
108-
$this->assertEquals($expectedResult, $this->model->isSetFlag($path));
76+
$this->assertEquals($expectedResult, $this->model->isSetFlag($configPath));
10977
}
11078

11179
public function isSetFlagDataProvider()
11280
{
11381
return [
114-
[0, false],
115-
[true, true],
116-
['0', false],
117-
['', false],
118-
['some string', true],
119-
[1, true]
82+
['a', 0, false],
83+
['b', true, true],
84+
['c', '0', false],
85+
['d', '', false],
86+
['e', 'some string', true],
87+
['f', 1, true]
12088
];
12189
}
12290

app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ class Suffix extends \Magento\Framework\App\Config\Value
4141
protected $resource;
4242

4343
/**
44-
* @var \Magento\Framework\App\Config\ScopePool
44+
* @var \Magento\Framework\App\Config
4545
*/
46-
private $scopePool;
46+
private $appConfig;
4747

4848
/**
4949
* @param \Magento\Framework\Model\Context $context
@@ -83,17 +83,17 @@ public function __construct(
8383
/**
8484
* Get instance of ScopePool
8585
*
86-
* @return \Magento\Framework\App\Config\ScopePool
86+
* @return \Magento\Framework\App\Config
8787
* @deprecated
8888
*/
89-
private function getScopePool()
89+
private function getAppConfig()
9090
{
91-
if ($this->scopePool === null) {
92-
$this->scopePool = \Magento\Framework\App\ObjectManager::getInstance()->get(
93-
\Magento\Framework\App\Config\ScopePool::class
91+
if ($this->appConfig === null) {
92+
$this->appConfig = \Magento\Framework\App\ObjectManager::getInstance()->get(
93+
\Magento\Framework\App\Config::class
9494
);
9595
}
96-
return $this->scopePool;
96+
return $this->appConfig;
9797
}
9898

9999
/**
@@ -177,7 +177,7 @@ protected function updateSuffixForUrlRewrites()
177177
if ($this->getValue() !== null) {
178178
$suffix = $this->getValue();
179179
} else {
180-
$this->getScopePool()->clean();
180+
$this->getAppConfig()->clean();
181181
$suffix = $this->_config->getValue($this->getPath());
182182
}
183183
foreach ($entities as $urlRewrite) {

app/code/Magento/Catalog/Model/Template/Filter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
*/
1515
namespace Magento\Catalog\Model\Template;
1616

17+
/**
18+
* Work with catalog(store, website) urls
19+
*
20+
* @package Magento\Catalog\Model\Template
21+
*/
1722
class Filter extends \Magento\Framework\Filter\Template
1823
{
1924
/**

0 commit comments

Comments
 (0)