Skip to content

Commit dfb0b5d

Browse files
author
Oleksandr Iegorov
committed
Merge branch '2.2-develop' of github.com:magento/magento2ce into MAGETWO-69940
2 parents 5683c42 + 22eac8e commit dfb0b5d

File tree

24 files changed

+715
-82
lines changed

24 files changed

+715
-82
lines changed

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,16 @@
139139
<type name="Magento\Backend\Model\Menu\Builder">
140140
<plugin name="SetupMenuBuilder" type="Magento\Backend\Model\Setup\MenuBuilder" />
141141
</type>
142-
<type name="Magento\Config\Model\Config\Structure\ConcealInProductionConfigList">
142+
<type name="Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProduction">
143143
<arguments>
144144
<argument name="configs" xsi:type="array">
145145
<item name="dev" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::HIDDEN</item>
146+
</argument>
147+
</arguments>
148+
</type>
149+
<type name="Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProductionWithoutScdOnDemand">
150+
<arguments>
151+
<argument name="configs" xsi:type="array">
146152
<item name="general/locale/code" xsi:type="const">Magento\Config\Model\Config\Structure\ElementVisibilityInterface::DISABLED</item>
147153
</argument>
148154
</arguments>

app/code/Magento/Captcha/i18n/en_US.csv

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ Forms,Forms
2020
"Number of Symbols","Number of Symbols"
2121
"Please specify 8 symbols at the most. Range allowed (e.g. 3-5)","Please specify 8 symbols at the most. Range allowed (e.g. 3-5)"
2222
"Symbols Used in CAPTCHA","Symbols Used in CAPTCHA"
23-
"
24-
Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.<br />Similar looking characters (e.g. ""i"", ""l"", ""1"") decrease chance of correct recognition by customer.
25-
","
26-
Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.<br />Similar looking characters (e.g. ""i"", ""l"", ""1"") decrease chance of correct recognition by customer.
27-
"
23+
"Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.<br />Similar looking characters (e.g. ""i"", ""l"", ""1"") decrease chance of correct recognition by customer.","Please use only letters (a-z or A-Z) or numbers (0-9) in this field. No spaces or other characters are allowed.<br />Similar looking characters (e.g. ""i"", ""l"", ""1"") decrease chance of correct recognition by customer."
2824
"Case Sensitive","Case Sensitive"
2925
"Enable CAPTCHA on Storefront","Enable CAPTCHA on Storefront"
3026
"CAPTCHA for ""Create user"" and ""Forgot password"" forms is always enabled if chosen.","CAPTCHA for ""Create user"" and ""Forgot password"" forms is always enabled if chosen."

app/code/Magento/Catalog/Model/Product/Type/AbstractType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public function getChildrenIds($parentId, $required = true)
251251
}
252252

253253
/**
254-
* Retrieve parent ids array by requered child
254+
* Retrieve parent ids array by required child
255255
*
256256
* @param int|array $childId
257257
* @return array

app/code/Magento/Config/Block/System/Config/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ protected function _getAdditionalElementTypes()
709709
}
710710

711711
/**
712-
* Temporary moved those $this->getRequest()->getParam('blabla') from the code accross this block
712+
* Temporary moved those $this->getRequest()->getParam('blabla') from the code across this block
713713
* to getBlala() methods to be later set from controller with setters
714714
*/
715715

app/code/Magento/Config/Model/Config/Structure/ConcealInProductionConfigList.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
* Defines status of visibility of form elements on Stores > Settings > Configuration page
1212
* in Admin Panel in Production mode.
1313
* @api
14-
* @since 100.2.0
14+
* @deprecated class location was changed
15+
* @see \Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProduction
1516
*/
1617
class ConcealInProductionConfigList implements ElementVisibilityInterface
1718
{
@@ -54,7 +55,7 @@ public function __construct(State $state, array $configs = [])
5455

5556
/**
5657
* @inheritdoc
57-
* @since 100.2.0
58+
* @deprecated
5859
*/
5960
public function isHidden($path)
6061
{
@@ -66,7 +67,7 @@ public function isHidden($path)
6667

6768
/**
6869
* @inheritdoc
69-
* @since 100.2.0
70+
* @deprecated
7071
*/
7172
public function isDisabled($path)
7273
{
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Config\Model\Config\Structure\ElementVisibility;
9+
10+
use Magento\Config\Model\Config\Structure\ElementVisibilityInterface;
11+
use Magento\Framework\App\State;
12+
13+
/**
14+
* Defines status of visibility of form elements on Stores > Settings > Configuration page
15+
* in Admin Panel in Production mode.
16+
* @api
17+
*/
18+
class ConcealInProduction implements ElementVisibilityInterface
19+
{
20+
/**
21+
* The list of form element paths with concrete visibility status.
22+
*
23+
* E.g.
24+
*
25+
* ```php
26+
* [
27+
* 'general/locale/code' => ElementVisibilityInterface::DISABLED,
28+
* 'general/country' => ElementVisibilityInterface::HIDDEN,
29+
* ];
30+
* ```
31+
*
32+
* It means that:
33+
* - field Locale (in group Locale Options in section General) will be disabled
34+
* - group Country Options (in section General) will be hidden
35+
*
36+
* @var array
37+
*/
38+
private $configs = [];
39+
40+
/**
41+
* The object that has information about the state of the system.
42+
*
43+
* @var State
44+
*/
45+
private $state;
46+
47+
/**
48+
*
49+
* The list of form element paths which ignore visibility status.
50+
*
51+
* E.g.
52+
*
53+
* ```php
54+
* [
55+
* 'general/country/default' => '',
56+
* ];
57+
* ```
58+
*
59+
* It means that:
60+
* - field 'default' in group Country Options (in section General) will be showed, even if all group(section)
61+
* will be hidden.
62+
*
63+
* @var array
64+
*/
65+
private $exemptions = [];
66+
67+
/**
68+
* @param State $state The object that has information about the state of the system
69+
* @param array $configs The list of form element paths with concrete visibility status.
70+
* @param array $exemptions The list of form element paths which ignore visibility status.
71+
*/
72+
public function __construct(State $state, array $configs = [], array $exemptions = [])
73+
{
74+
$this->state = $state;
75+
$this->configs = $configs;
76+
$this->exemptions = $exemptions;
77+
}
78+
79+
/**
80+
* @inheritdoc
81+
* @since 100.2.0
82+
*/
83+
public function isHidden($path)
84+
{
85+
$path = $this->normalizePath($path);
86+
if ($this->state->getMode() === State::MODE_PRODUCTION
87+
&& preg_match('/(?<group>(?<section>.*?)\/.*?)\/.*?/', $path, $match)) {
88+
$group = $match['group'];
89+
$section = $match['section'];
90+
$exemptions = array_keys($this->exemptions);
91+
$checkedItems = [];
92+
foreach ([$path, $group, $section] as $itemPath) {
93+
$checkedItems[] = $itemPath;
94+
if (!empty($this->configs[$itemPath])) {
95+
return $this->configs[$itemPath] === static::HIDDEN
96+
&& empty(array_intersect($checkedItems, $exemptions));
97+
}
98+
}
99+
}
100+
101+
return false;
102+
}
103+
104+
/**
105+
* @inheritdoc
106+
* @since 100.2.0
107+
*/
108+
public function isDisabled($path)
109+
{
110+
$path = $this->normalizePath($path);
111+
if ($this->state->getMode() === State::MODE_PRODUCTION) {
112+
while (true) {
113+
if (!empty($this->configs[$path])) {
114+
return $this->configs[$path] === static::DISABLED;
115+
}
116+
117+
$position = strripos($path, '/');
118+
if ($position === false) {
119+
break;
120+
}
121+
$path = substr($path, 0, $position);
122+
}
123+
}
124+
125+
return false;
126+
}
127+
128+
/**
129+
* Returns normalized path.
130+
*
131+
* @param string $path The path to be normalized
132+
* @return string The normalized path
133+
*/
134+
private function normalizePath($path)
135+
{
136+
return trim($path, '/');
137+
}
138+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Config\Model\Config\Structure\ElementVisibility;
9+
10+
use Magento\Config\Model\Config\Structure\ElementVisibilityInterface;
11+
use Magento\Framework\App\DeploymentConfig;
12+
use Magento\Framework\Config\ConfigOptionsListConstants as Constants;
13+
14+
/**
15+
* Defines status of visibility of form elements on Stores > Settings > Configuration page
16+
* when Constants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION is enabled
17+
* otherwise rule from Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProduction is used
18+
* @see \Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProduction
19+
*
20+
* @api
21+
*/
22+
class ConcealInProductionWithoutScdOnDemand implements ElementVisibilityInterface
23+
{
24+
/**
25+
* @var ConcealInProduction Element visibility rules in the Production mode
26+
*/
27+
private $concealInProduction;
28+
29+
/**
30+
* @var DeploymentConfig The application deployment configuration
31+
*/
32+
private $deploymentConfig;
33+
34+
/**
35+
* @param ConcealInProductionFactory $concealInProductionFactory
36+
* @param DeploymentConfig $deploymentConfig Deployment configuration reader
37+
* @param array $configs The list of form element paths with concrete visibility status.
38+
* @param array $exemptions The list of form element paths which ignore visibility status.
39+
*/
40+
public function __construct(
41+
ConcealInProductionFactory $concealInProductionFactory,
42+
DeploymentConfig $deploymentConfig,
43+
array $configs = [],
44+
array $exemptions = []
45+
) {
46+
$this->concealInProduction = $concealInProductionFactory
47+
->create(['configs' => $configs, 'exemptions' => $exemptions]);
48+
$this->deploymentConfig = $deploymentConfig;
49+
}
50+
51+
/**
52+
* @inheritdoc
53+
*/
54+
public function isHidden($path): bool
55+
{
56+
if (!$this->deploymentConfig->getConfigData(Constants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION)) {
57+
return $this->concealInProduction->isHidden($path);
58+
}
59+
return false;
60+
}
61+
62+
/**
63+
* @inheritdoc
64+
*/
65+
public function isDisabled($path): bool
66+
{
67+
if (!$this->deploymentConfig->getConfigData(Constants::CONFIG_PATH_SCD_ON_DEMAND_IN_PRODUCTION)) {
68+
return $this->concealInProduction->isDisabled($path);
69+
}
70+
return false;
71+
}
72+
}

app/code/Magento/Config/Test/Unit/Model/Config/Structure/ConcealInProductionConfigListTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
use Magento\Config\Model\Config\Structure\ConcealInProductionConfigList;
99
use Magento\Framework\App\State;
1010

11+
/**
12+
* @deprecated Original class has changed the location
13+
* @see \Magento\Config\Model\Config\Structure\ElementVisibility\ConcealInProduction
14+
* @see \Magento\Config\Test\Unit\Model\Config\Structure\ElementVisibility\ConcealInProductionTest
15+
*/
1116
class ConcealInProductionConfigListTest extends \PHPUnit\Framework\TestCase
1217
{
1318
/**
@@ -43,6 +48,8 @@ protected function setUp()
4348
* @param string $mageMode
4449
* @param bool $expectedResult
4550
* @dataProvider disabledDataProvider
51+
*
52+
* @deprecated
4653
*/
4754
public function testIsDisabled($path, $mageMode, $expectedResult)
4855
{
@@ -54,6 +61,8 @@ public function testIsDisabled($path, $mageMode, $expectedResult)
5461

5562
/**
5663
* @return array
64+
*
65+
* @deprecated
5766
*/
5867
public function disabledDataProvider()
5968
{
@@ -78,6 +87,8 @@ public function disabledDataProvider()
7887
* @param string $mageMode
7988
* @param bool $expectedResult
8089
* @dataProvider hiddenDataProvider
90+
*
91+
* @deprecated
8192
*/
8293
public function testIsHidden($path, $mageMode, $expectedResult)
8394
{
@@ -89,6 +100,8 @@ public function testIsHidden($path, $mageMode, $expectedResult)
89100

90101
/**
91102
* @return array
103+
*
104+
* @deprecated
92105
*/
93106
public function hiddenDataProvider()
94107
{

0 commit comments

Comments
 (0)