Skip to content

Commit 80ace5c

Browse files
author
Bohdan Korablov
committed
Merge remote-tracking branch 'falcons/MAGETWO-67159' into MAGETWO-69983
# Conflicts: # app/code/Magento/Config/Model/Config/Importer.php # app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php
2 parents c438943 + 82905a7 commit 80ace5c

File tree

5 files changed

+28
-57
lines changed

5 files changed

+28
-57
lines changed

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

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
use Magento\Framework\App\State;
1414
use Magento\Framework\Config\ScopeInterface;
1515
use Magento\Framework\Exception\State\InvalidTransitionException;
16-
use Magento\Framework\Flag\FlagResource;
17-
use Magento\Framework\FlagFactory;
16+
use Magento\Framework\FlagManager;
1817
use Magento\Framework\Stdlib\ArrayUtils;
1918

2019
/**
@@ -32,18 +31,11 @@ class Importer implements ImporterInterface
3231
const FLAG_CODE = 'system_config_snapshot';
3332

3433
/**
35-
* The flag factory.
34+
* The flag manager.
3635
*
37-
* @var FlagFactory
36+
* @var FlagManager
3837
*/
39-
private $flagFactory;
40-
41-
/**
42-
* The flag resource.
43-
*
44-
* @var FlagResource
45-
*/
46-
private $flagResource;
38+
private $flagManager;
4739

4840
/**
4941
* An array utils.
@@ -81,25 +73,22 @@ class Importer implements ImporterInterface
8173
private $saveProcessor;
8274

8375
/**
84-
* @param FlagFactory $flagFactory The flag factory
85-
* @param FlagResource $flagResource The flag resource
76+
* @param FlagManager $flagManager The flag manager
8677
* @param ArrayUtils $arrayUtils An array utils
8778
* @param SaveProcessor $saveProcessor Saves configuration data
8879
* @param ScopeConfigInterface $scopeConfig The application config storage.
8980
* @param State $state The application scope to run
9081
* @param ScopeInterface $scope The application scope
9182
*/
9283
public function __construct(
93-
FlagFactory $flagFactory,
94-
FlagResource $flagResource,
84+
FlagManager $flagManager,
9585
ArrayUtils $arrayUtils,
9686
SaveProcessor $saveProcessor,
9787
ScopeConfigInterface $scopeConfig,
9888
State $state,
9989
ScopeInterface $scope
10090
) {
101-
$this->flagFactory = $flagFactory;
102-
$this->flagResource = $flagResource;
91+
$this->flagManager = $flagManager;
10392
$this->arrayUtils = $arrayUtils;
10493
$this->saveProcessor = $saveProcessor;
10594
$this->scopeConfig = $scopeConfig;
@@ -118,13 +107,10 @@ public function import(array $data)
118107
$currentScope = $this->scope->getCurrentScope();
119108

120109
try {
121-
$flag = $this->flagFactory->create(['data' => ['flag_code' => static::FLAG_CODE]]);
122-
$this->flagResource->load($flag, static::FLAG_CODE, 'flag_code');
123-
$previouslyProcessedData = $flag->getFlagData() ?: [];
124-
110+
$savedFlag = $this->flagManager->getFlagData(static::FLAG_CODE) ?: [];
125111
$changedData = array_replace_recursive(
126-
$this->arrayUtils->recursiveDiff($previouslyProcessedData, $data),
127-
$this->arrayUtils->recursiveDiff($data, $previouslyProcessedData)
112+
$this->arrayUtils->recursiveDiff($savedFlag, $data),
113+
$this->arrayUtils->recursiveDiff($data, $savedFlag)
128114
);
129115

130116
/**
@@ -142,8 +128,7 @@ public function import(array $data)
142128
$this->saveProcessor->process($changedData);
143129
});
144130

145-
$flag->setFlagData($data);
146-
$this->flagResource->save($flag);
131+
$this->flagManager->saveFlag(static::FLAG_CODE, $data);
147132
} catch (\Exception $e) {
148133
throw new InvalidTransitionException(__('%1', $e->getMessage()), $e);
149134
} finally {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public function __construct(
8080
* @return ValueInterface
8181
* @throws RuntimeException If Value can not be created
8282
* @see ValueInterface
83-
* @see Value
8483
*/
8584
public function create($path, $value, $scope, $scopeCode = null)
8685
{

app/code/Magento/Config/Test/Unit/Model/Config/ImporterTest.php

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\Framework\Config\ScopeInterface;
1616
use Magento\Framework\Flag;
1717
use Magento\Framework\Flag\FlagResource;
18-
use Magento\Framework\FlagFactory;
18+
use Magento\Framework\FlagManager;
1919
use Magento\Framework\Stdlib\ArrayUtils;
2020
use PHPUnit_Framework_MockObject_MockObject as Mock;
2121

@@ -33,20 +33,15 @@ class ImporterTest extends \PHPUnit_Framework_TestCase
3333
private $model;
3434

3535
/**
36-
* @var FlagFactory|Mock
36+
* @var FlagManager|Mock
3737
*/
38-
private $flagFactoryMock;
38+
private $flagManagerMock;
3939

4040
/**
4141
* @var Flag|Mock
4242
*/
4343
private $flagMock;
4444

45-
/**
46-
* @var FlagResource|Mock
47-
*/
48-
private $flagResourceMock;
49-
5045
/**
5146
* @var ArrayUtils|Mock
5247
*/
@@ -87,7 +82,7 @@ class ImporterTest extends \PHPUnit_Framework_TestCase
8782
*/
8883
protected function setUp()
8984
{
90-
$this->flagFactoryMock = $this->getMockBuilder(FlagFactory::class)
85+
$this->flagManagerMock = $this->getMockBuilder(FlagManager::class)
9186
->disableOriginalConstructor()
9287
->getMock();
9388
$this->flagMock = $this->getMockBuilder(Flag::class)
@@ -116,13 +111,12 @@ protected function setUp()
116111
->disableOriginalConstructor()
117112
->getMock();
118113

119-
$this->flagFactoryMock->expects($this->any())
114+
$this->flagManagerMock->expects($this->any())
120115
->method('create')
121116
->willReturn($this->flagMock);
122117

123118
$this->model = new Importer(
124-
$this->flagFactoryMock,
125-
$this->flagResourceMock,
119+
$this->flagManagerMock,
126120
$this->arrayUtilsMock,
127121
$this->saveProcessorMock,
128122
$this->scopeConfigMock,
@@ -136,11 +130,9 @@ public function testImport()
136130
$data = [];
137131
$currentData = ['current' => '2'];
138132

139-
$this->flagResourceMock->expects($this->once())
140-
->method('load')
141-
->with($this->flagMock, Importer::FLAG_CODE, 'flag_code');
142-
$this->flagMock->expects($this->once())
133+
$this->flagManagerMock->expects($this->once())
143134
->method('getFlagData')
135+
->with(Importer::FLAG_CODE)
144136
->willReturn($currentData);
145137
$this->arrayUtilsMock->expects($this->exactly(2))
146138
->method('recursiveDiff')
@@ -157,12 +149,9 @@ public function testImport()
157149
$this->scopeMock->expects($this->once())
158150
->method('setCurrentScope')
159151
->with('oldScope');
160-
$this->flagMock->expects($this->once())
161-
->method('setFlagData')
162-
->with($data);
163-
$this->flagResourceMock->expects($this->once())
164-
->method('save')
165-
->with($this->flagMock);
152+
$this->flagManagerMock->expects($this->once())
153+
->method('saveFlag')
154+
->with(Importer::FLAG_CODE, $data);
166155

167156
$this->assertSame(['System config was processed'], $this->model->import($data));
168157
}
@@ -176,10 +165,7 @@ public function testImportWithException()
176165
$data = [];
177166
$currentData = ['current' => '2'];
178167

179-
$this->flagResourceMock->expects($this->once())
180-
->method('load')
181-
->with($this->flagMock, Importer::FLAG_CODE, 'flag_code');
182-
$this->flagMock->expects($this->once())
168+
$this->flagManagerMock->expects($this->once())
183169
->method('getFlagData')
184170
->willReturn($currentData);
185171
$this->arrayUtilsMock->expects($this->exactly(2))

app/code/Magento/Deploy/Console/Command/App/SensitiveConfigSet/SensitiveConfigSetFacade.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ public function __construct(
7878
}
7979

8080
/**
81-
* Processes the sensitive:config:set command.
81+
* Processes the config:sensitive:set command.
8282
*
8383
* @param InputInterface $input The input manager
8484
* @param OutputInterface $output The output manager
8585
* @return void
86-
* @throws RuntimeException If data can not be processed
86+
* @throws LocalizedException If scope or scope code is not valid
87+
* @throws RuntimeException If sensitive config can not be filled
8788
*/
8889
public function process(InputInterface $input, OutputInterface $output)
8990
{

lib/internal/Magento/Framework/FlagManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(
4444
* Retrieves raw data from the flag.
4545
*
4646
* @param string $code The code of flag
47-
* @return mixed
47+
* @return string|int|float|bool|array|null
4848
*/
4949
public function getFlagData($code)
5050
{
@@ -55,7 +55,7 @@ public function getFlagData($code)
5555
* Saves the flag value by code.
5656
*
5757
* @param string $code The code of flag
58-
* @param mixed $value The value of flag
58+
* @param string|int|float|bool|array|null $value The value of flag
5959
* @return bool
6060
*/
6161
public function saveFlag($code, $value)

0 commit comments

Comments
 (0)