Skip to content

Commit 9305bfb

Browse files
author
Bohdan Korablov
committed
Merge remote-tracking branch 'falcons/MAGETWO-65085' into MAGETWO-65208
# Conflicts: # app/code/Magento/Deploy/Model/DeploymentConfig/DataCollector.php # app/code/Magento/Deploy/Model/DeploymentConfig/Hash.php # app/code/Magento/Deploy/Model/DeploymentConfig/Validator.php
2 parents c23a794 + f1fd57a commit 9305bfb

File tree

20 files changed

+203
-78
lines changed

20 files changed

+203
-78
lines changed

app/code/Magento/Backend/Block/System/Account/Edit/Form.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Backend\Block\System\Account\Edit;
77

88
use Magento\Framework\App\ObjectManager;
9-
use Magento\Framework\Locale\Deployed\OptionInterface;
9+
use Magento\Framework\Locale\OptionInterface;
1010

1111
/**
1212
* Adminhtml edit admin user account form
@@ -135,7 +135,7 @@ protected function _prepareForm()
135135
'name' => 'interface_locale',
136136
'label' => __('Interface Locale'),
137137
'title' => __('Interface Locale'),
138-
'values' => $this->deployedLocales->getTranslatedLocales(),
138+
'values' => $this->deployedLocales->getTranslatedOptionLocales(),
139139
'class' => 'select'
140140
]
141141
);

app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ class ValueProcessor
2121
{
2222
/**
2323
* Placeholder for the output of sensitive data.
24-
*
25-
* @const
2624
*/
2725
const SAFE_PLACEHOLDER = '******';
2826

@@ -63,7 +61,7 @@ public function __construct(
6361
}
6462

6563
/**
66-
* Processes value using backend model.
64+
* Processes value to display using backend model.
6765
*
6866
* @param string $scope The scope of configuration. E.g. 'default', 'website' or 'store'
6967
* @param string $scopeCode The scope code of configuration
@@ -86,14 +84,17 @@ public function process($scope, $scopeCode, $value, $path)
8684
$backendModel = $field && $field->hasBackendModel()
8785
? $field->getBackendModel()
8886
: $this->configValueFactory->create();
87+
88+
if ($backendModel instanceof Encrypted) {
89+
return $value ? self::SAFE_PLACEHOLDER : null;
90+
}
91+
8992
$backendModel->setPath($path);
9093
$backendModel->setScope($scope);
9194
$backendModel->setScopeId($scopeCode);
9295
$backendModel->setValue($value);
9396
$backendModel->afterLoad();
9497

95-
return ($backendModel instanceof Encrypted) && !empty($backendModel->getValue())
96-
? self::SAFE_PLACEHOLDER
97-
: $backendModel->getValue();
98+
return $backendModel->getValue();
9899
}
99100
}

app/code/Magento/Config/Console/Command/ConfigShowCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
144144
try {
145145
$this->scope = $input->getOption(self::INPUT_OPTION_SCOPE);
146146
$this->scopeCode = $input->getOption(self::INPUT_OPTION_SCOPE_CODE);
147-
$this->inputPath = trim($input->getArgument(self::INPUT_ARGUMENT_PATH), "/");
147+
$this->inputPath = trim($input->getArgument(self::INPUT_ARGUMENT_PATH), '/');
148148

149149
$this->scopeValidator->isValid($this->scope, $this->scopeCode);
150150
$configPath = $this->pathResolver->resolve($this->inputPath, $this->scope, $this->scopeCode);

app/code/Magento/Config/Model/Config/PathValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public function __construct(Structure $structure)
2828
}
2929

3030
/**
31-
* Validates the config path by config structure schema.
31+
* Checks whether the config path present in configuration structure.
3232
*
3333
* @param string $path The config path
34-
* @return bool The result of validation
34+
* @return true The result of validation
3535
* @throws ValidatorException If provided path is not valid
3636
*/
3737
public function validate($path)

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

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -252,15 +252,38 @@ protected function _getGroupFieldPathsByAttribute(array $fields, $parentPath, $a
252252
}
253253

254254
/**
255-
* Collects config field paths recursively from config schema.
256-
* Returns an array map of fields specification.
255+
* Collects config paths and their structure paths from configuration files.
256+
* Returns the map of config paths and their structure paths.
257257
*
258-
* ```php
259-
* [
260-
* 'test_config/test_config/test_config' => [
261-
* 'test_structure/test_structure/test_structure'
262-
* ]
258+
* All paths are declared in module's system.xml.
259+
*
260+
* ```xml
261+
* <section id="section_id">
262+
* <group id="group_id" ...>
263+
* <field id="field_one_id" ...>
264+
* <label>Field One</label>
265+
* ...
266+
* </field>
267+
* <field id="field_two_id" ...>
268+
* <label>Field Two</label>
269+
* <config_path>section/group/field</config_path>
270+
* ...
271+
* </field>
272+
* </group>
273+
* </section>
263274
* ```
275+
* If <config_path> node does not exist, then config path duplicates structure path.
276+
* The result of this example will be:
277+
*
278+
* ```php
279+
* [
280+
* 'section_id/group_id/field_one_id' => [
281+
* 'section_id/group_id/field_one_id'
282+
* ],
283+
* 'section/group/field' => [
284+
* 'section_id/group_id/field_two_id'
285+
* ]
286+
*```
264287
*
265288
* @return array An array of config path to config structure path map
266289
*/
@@ -272,7 +295,7 @@ public function getFieldPaths()
272295
}
273296

274297
/**
275-
* Iteration that collects config field paths recursively from config schema.
298+
* Iteration that collects config field paths recursively from config files.
276299
*
277300
* @param array $elements The elements to be parsed
278301
* @return array An array of config path to config structure path map

app/code/Magento/Config/Test/Unit/Console/Command/ConfigShow/ValueProcessorTest.php

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,33 @@ protected function setUp()
6666
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsGetBackendModel
6767
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsCreate
6868
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsGetValue
69+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetPath
70+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetScope
71+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetScopeId
72+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsSetValue
73+
* @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectsAfterLoad
6974
* @param string $expectsValue
7075
* @param string $className
76+
* @param string $value
7177
* @dataProvider processDataProvider
78+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
7279
*/
7380
public function testProcess(
7481
$hasBackendModel,
7582
$expectsGetBackendModel,
7683
$expectsCreate,
7784
$expectsGetValue,
85+
$expectsSetPath,
86+
$expectsSetScope,
87+
$expectsSetScopeId,
88+
$expectsSetValue,
89+
$expectsAfterLoad,
7890
$expectsValue,
79-
$className
91+
$className,
92+
$value
8093
) {
8194
$scope = 'someScope';
8295
$scopeCode = 'someScopeCode';
83-
$value = 'someValue';
8496
$path = 'some/config/path';
8597
$oldConfigScope = 'oldConfigScope';
8698

@@ -107,23 +119,23 @@ public function testProcess(
107119
->disableOriginalConstructor()
108120
->setMethods(['setPath', 'setScope', 'setScopeId', 'setValue', 'getValue', 'afterLoad'])
109121
->getMock();
110-
$backendModelMock->expects($this->once())
122+
$backendModelMock->expects($expectsSetPath)
111123
->method('setPath')
112124
->with($path)
113125
->willReturnSelf();
114-
$backendModelMock->expects($this->once())
126+
$backendModelMock->expects($expectsSetScope)
115127
->method('setScope')
116128
->with($scope)
117129
->willReturnSelf();
118-
$backendModelMock->expects($this->once())
130+
$backendModelMock->expects($expectsSetScopeId)
119131
->method('setScopeId')
120132
->with($scopeCode)
121133
->willReturnSelf();
122-
$backendModelMock->expects($this->once())
134+
$backendModelMock->expects($expectsSetValue)
123135
->method('setValue')
124136
->with($value)
125137
->willReturnSelf();
126-
$backendModelMock->expects($this->once())
138+
$backendModelMock->expects($expectsAfterLoad)
127139
->method('afterLoad')
128140
->willReturnSelf();
129141
$backendModelMock->expects($expectsGetValue)
@@ -154,6 +166,7 @@ public function testProcess(
154166

155167
/**
156168
* @return array
169+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
157170
*/
158171
public function processDataProvider()
159172
{
@@ -163,24 +176,70 @@ public function processDataProvider()
163176
'expectsGetBackendModel' => $this->once(),
164177
'expectsCreate' => $this->never(),
165178
'expectsGetValue' => $this->once(),
179+
'expectsSetPath' => $this->once(),
180+
'expectsSetScope' => $this->once(),
181+
'expectsSetScopeId' => $this->once(),
182+
'expectsSetValue' => $this->once(),
183+
'expectsAfterLoad' => $this->once(),
166184
'expectsValue' => 'someValue',
167-
'className' => Value::class
185+
'className' => Value::class,
186+
'value' => 'someValue'
168187
],
169188
[
170189
'hasBackendModel' => false,
171190
'expectsGetBackendModel' => $this->never(),
172191
'expectsCreate' => $this->once(),
173192
'expectsGetValue' => $this->once(),
193+
'expectsSetPath' => $this->once(),
194+
'expectsSetScope' => $this->once(),
195+
'expectsSetScopeId' => $this->once(),
196+
'expectsSetValue' => $this->once(),
197+
'expectsAfterLoad' => $this->once(),
174198
'expectsValue' => 'someValue',
175-
'className' => Value::class
199+
'className' => Value::class,
200+
'value' => 'someValue'
176201
],
177202
[
178203
'hasBackendModel' => true,
179204
'expectsGetBackendModel' => $this->once(),
180205
'expectsCreate' => $this->never(),
181-
'expectsGetValue' => $this->once(),
206+
'expectsGetValue' => $this->never(),
207+
'expectsSetPath' => $this->never(),
208+
'expectsSetScope' => $this->never(),
209+
'expectsSetScopeId' => $this->never(),
210+
'expectsSetValue' => $this->never(),
211+
'expectsAfterLoad' => $this->never(),
182212
'expectsValue' => ValueProcessor::SAFE_PLACEHOLDER,
183213
'className' => Encrypted::class,
214+
'value' => 'someValue'
215+
],
216+
[
217+
'hasBackendModel' => true,
218+
'expectsGetBackendModel' => $this->once(),
219+
'expectsCreate' => $this->never(),
220+
'expectsGetValue' => $this->once(),
221+
'expectsSetPath' => $this->once(),
222+
'expectsSetScope' => $this->once(),
223+
'expectsSetScopeId' => $this->once(),
224+
'expectsSetValue' => $this->once(),
225+
'expectsAfterLoad' => $this->once(),
226+
'expectsValue' => null,
227+
'className' => Value::class,
228+
'value' => null
229+
],
230+
[
231+
'hasBackendModel' => true,
232+
'expectsGetBackendModel' => $this->once(),
233+
'expectsCreate' => $this->never(),
234+
'expectsGetValue' => $this->never(),
235+
'expectsSetPath' => $this->never(),
236+
'expectsSetScope' => $this->never(),
237+
'expectsSetScopeId' => $this->never(),
238+
'expectsSetValue' => $this->never(),
239+
'expectsAfterLoad' => $this->never(),
240+
'expectsValue' => null,
241+
'className' => Encrypted::class,
242+
'value' => null
184243
],
185244
];
186245
}

app/code/Magento/Deploy/Console/Command/App/ConfigImport/Importer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class Importer
2222
{
2323
/**
24-
* The manager of deployment configuration hash.
24+
* The configuration data validator.
2525
*
2626
* @var Validator
2727
*/

app/code/Magento/Deploy/Console/Command/App/ConfigImportCommand.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414
use Magento\Framework\App\DeploymentConfig\Writer;
1515

1616
/**
17-
* Imports data from deployment configuration files to the DB.
17+
* Runs the process of importing configuration data from shared source to appropriate application sources.
1818
*
1919
* We have configuration files that are shared between environments, but some of the configurations are read only
20-
* from DB (e.g., themes, scopes and etc). This command is used to import such configurations from the file to DB.
20+
* from DB (e.g., themes, scopes and etc). This command is used to import such configurations from the file to
21+
* appropriate application sources.
2122
*/
2223
class ConfigImportCommand extends Command
2324
{

app/code/Magento/Deploy/Model/DeploymentConfig/DataCollector.php

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,34 @@
88
use Magento\Framework\App\DeploymentConfig;
99

1010
/**
11-
* Config data collector of specific sections which are defined in di.xml
11+
* Config data collector of specific sections in configuration files which are defined in di.xml
12+
*
13+
* E.g., definition of sections which are needed to import:
14+
* ```xml
15+
* <type name="Magento\Deploy\Model\DeploymentConfig\ImporterPool">
16+
* <arguments>
17+
* <argument name="importers" xsi:type="array">
18+
* <item name="scopes" xsi:type="string">Magento\Store\Model\StoreImporter</item>
19+
* </argument>
20+
* </arguments>
21+
* </type>
22+
* ```
23+
* Example, how sections are stored with their config data in configuration files:
24+
* ```php
25+
* [
26+
* 'scopes' => [...],
27+
* 'system' => [...],
28+
* 'themes' => [...],
29+
* ...
30+
* ]
31+
* ```
32+
*
33+
* In here we define section "scopes" and its importer Magento\Store\Model\StoreImporter.
34+
* The data of this section will be collected then will be used in importing process from the shared configuration
35+
* files to appropriate application sources.
36+
*
37+
* @see \Magento\Deploy\Console\Command\App\ConfigImport\Importer::import()
38+
* @see \Magento\Deploy\Model\DeploymentConfig\Hash::regenerate()
1239
*/
1340
class DataCollector
1441
{
@@ -37,11 +64,22 @@ public function __construct(ImporterPool $configImporterPool, DeploymentConfig $
3764
}
3865

3966
/**
40-
* Retrieves configuration data of all specific sections from deployment configuration files.
67+
* Retrieves configuration data of specific section from deployment configuration files.
4168
* Or retrieves configuration data of specific sections by its name.
4269
*
70+
* E.g.
71+
* ```php
72+
* [
73+
* 'scopes' => [...],
74+
* 'system' => [...],
75+
* 'themes' => [...],
76+
* ...
77+
* ]
78+
* ```
79+
* In this example key of the array is the section name, value of the array is configuration data of the section.
80+
*
4381
* @param string $sectionName the section name for retrieving its configuration data
44-
* @return array is configurations data from deployment configuration files
82+
* @return array
4583
*/
4684
public function getConfig($sectionName = null)
4785
{

app/code/Magento/Deploy/Model/DeploymentConfig/Hash.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212

1313
/**
1414
* Saves and Retrieves deployment configuration hash.
15+
*
16+
* This hash keeps version of last imported data. Hash is used to define whether data was updated
17+
* and import is required.
18+
*
19+
* @see \Magento\Deploy\Model\DeploymentConfig\Validator::isValid()
1520
*/
1621
class Hash
1722
{
@@ -71,10 +76,11 @@ public function __construct(
7176
*
7277
* If the specific section name is set, then hash will be updated only for this section,
7378
* in another case hash will be updated for all sections which defined in di.xml
79+
* The hash is generated based on data from configuration files.
7480
*
7581
* @param string $sectionName the specific section name
7682
* @return void
77-
* @throws LocalizedException is thrown when hash is not saved in a storage
83+
* @throws LocalizedException is thrown when hash was not saved
7884
*/
7985
public function regenerate($sectionName = null)
8086
{

0 commit comments

Comments
 (0)