Skip to content

Commit 20f7197

Browse files
Merge branch 'MAGETWO-63084' of https://github.com/magento-falcons/magento2ce into MAGETWO-65085
2 parents d11bc6d + d684eef commit 20f7197

File tree

7 files changed

+68
-11
lines changed

7 files changed

+68
-11
lines changed

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

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

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
use Magento\Deploy\Console\Command\App\ConfigImport\Importer;
1414

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

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

Lines changed: 39 additions & 1 deletion
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
{
@@ -39,6 +66,17 @@ public function __construct(ImporterPool $configImporterPool, DeploymentConfig $
3966
/**
4067
* Retrieves configuration data of specific section from deployment configuration files.
4168
*
69+
* E.g.
70+
* ```php
71+
* [
72+
* 'scopes' => [...],
73+
* 'system' => [...],
74+
* 'themes' => [...],
75+
* ...
76+
* ]
77+
* ```
78+
* In this example key of the array is the section name, value of the array is configuration data of the section.
79+
*
4280
* @return array
4381
*/
4482
public function getConfig()

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313

1414
/**
1515
* Saves and Retrieves deployment configuration hash.
16+
*
17+
* This hash keeps version of last imported data. Hash is used to define whether data was updated
18+
* and import is required.
19+
*
20+
* @see \Magento\Deploy\Model\DeploymentConfig\Validator::isValid()
1621
*/
1722
class Hash
1823
{
@@ -70,8 +75,10 @@ public function __construct(
7075
/**
7176
* Updates hash in the storage.
7277
*
78+
* The hash is generated based on data from configuration files
79+
*
7380
* @return void
74-
* @throws LocalizedException
81+
* @throws LocalizedException is thrown when hash was not saved
7582
*/
7683
public function regenerate()
7784
{

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

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

1313
/**
1414
* Pool of all deployment configuration importers.
15+
*
16+
* All importers should implement Magento\Framework\App\DeploymentConfig\ImporterInterface interface.
1517
*/
1618
class ImporterPool
1719
{
@@ -70,7 +72,8 @@ public function __construct(ObjectManagerInterface $objectManager, array $import
7072
}
7173

7274
/**
73-
* Retrieves sections from deployment configuration files which need to import into the DB.
75+
* Retrieves names of sections for configuration files whose data is read from these files for import
76+
* to appropriate application sources.
7477
*
7578
* @return array the list of sections
7679
* E.g.

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
/**
1111
* Configuration data validator of specific sections in the deployment configuration files.
12+
*
13+
* This validator checks that configuration data from specific sections was not changed.
14+
* If the data was changed validator returns false.
1215
*/
1316
class Validator
1417
{
@@ -49,9 +52,12 @@ public function __construct(
4952
}
5053

5154
/**
52-
* Check if config data in the deployment configuration files is valid.
55+
* Checks if config data in the deployment configuration files is valid.
5356
*
54-
* If config data is empty always returns true because it means that nothing to import.
57+
* Checks if config data was changed based on its hash.
58+
* If the new hash of config data and the saved hash are different returns false.
59+
* If config data is empty always returns true.
60+
* In the other cases returns true.
5561
*
5662
* @return bool
5763
*/

app/code/Magento/Deploy/Model/Plugin/ConfigValidator.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@
99
use Magento\Framework\App\FrontController;
1010
use Magento\Framework\App\RequestInterface;
1111
use Magento\Framework\Exception\LocalizedException;
12-
use Magento\Framework\Phrase;
1312

1413
/**
14+
* This is plugin for Magento\Framework\App\FrontController class.
15+
*
1516
* Checks that config data form deployment configuration files was not changed.
16-
* If config data was changed throws LocalizedException.
17+
* If config data was changed throws LocalizedException because we should stop work of Magento and then import
18+
* config data from shared configuration files into appropriate application sources.
1719
*/
1820
class ConfigValidator
1921
{
@@ -45,7 +47,7 @@ public function beforeDispatch(FrontController $subject, RequestInterface $reque
4547
{
4648
if (!$this->configValidator->isValid()) {
4749
throw new LocalizedException(
48-
new Phrase(
50+
__(
4951
'A change in configuration has been detected.'
5052
. ' Run app:config:import or setup:upgrade command to synchronize configuration.'
5153
)

0 commit comments

Comments
 (0)