Skip to content

Commit 28203b9

Browse files
committed
MDVA-267: Portdown MAGETWO-51807
- Backward-compatibility fixes
1 parent 7c6b8b5 commit 28203b9

File tree

6 files changed

+122
-13
lines changed

6 files changed

+122
-13
lines changed

setup/src/Magento/Setup/Controller/ComponentGrid.php

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,57 @@ class ComponentGrid extends \Zend\Mvc\Controller\AbstractActionController
5353
*/
5454
private $timezone;
5555

56+
/**
57+
* @var \Magento\Framework\ObjectManagerInterface
58+
*/
59+
private $objectManager;
60+
5661
/**
5762
* @param \Magento\Framework\Composer\ComposerInformation $composerInformation
5863
* @param \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider
5964
* @param \Magento\Setup\Model\UpdatePackagesCache $updatePackagesCache
6065
* @param \Magento\Setup\Model\MarketplaceManager $marketplaceManager
61-
* @param TimezoneProvider $tzProvider
6266
*/
6367
public function __construct(
6468
\Magento\Framework\Composer\ComposerInformation $composerInformation,
6569
\Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider,
6670
\Magento\Setup\Model\UpdatePackagesCache $updatePackagesCache,
67-
\Magento\Setup\Model\MarketplaceManager $marketplaceManager,
68-
TimezoneProvider $tzProvider
71+
\Magento\Setup\Model\MarketplaceManager $marketplaceManager
6972
) {
7073
$this->composerInformation = $composerInformation;
71-
$objectManager = $objectManagerProvider->get();
72-
$this->enabledModuleList = $objectManager->get('Magento\Framework\Module\ModuleList');
73-
$this->fullModuleList = $objectManager->get('Magento\Framework\Module\FullModuleList');
74-
$this->packageInfo = $objectManager->get('Magento\Framework\Module\PackageInfoFactory')->create();
74+
$this->objectManager = $objectManagerProvider->get();
75+
$this->enabledModuleList = $this->objectManager->get('Magento\Framework\Module\ModuleList');
76+
$this->fullModuleList = $this->objectManager->get('Magento\Framework\Module\FullModuleList');
77+
$this->packageInfo = $this->objectManager->get('Magento\Framework\Module\PackageInfoFactory')->create();
7578
$this->marketplaceManager = $marketplaceManager;
7679
$this->updatePackagesCache = $updatePackagesCache;
77-
$this->timezone = $tzProvider->get();
80+
}
81+
82+
/**
83+
* Get timezone
84+
*
85+
* @return \Magento\Framework\Stdlib\DateTime\TimezoneInterface|null
86+
*/
87+
private function getTimezone()
88+
{
89+
if ($this->timezone === null) {
90+
$this->timezone = $this->objectManager->get('Magento\Setup\Model\DateTime\TimezoneProvider')->get();
91+
}
92+
return $this->timezone;
93+
}
94+
95+
/**
96+
* Set timezone
97+
*
98+
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone
99+
* @throws \Exception
100+
*/
101+
public function setTimezone(\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone)
102+
{
103+
if ($this->timezone !== null) {
104+
throw new \Exception('timezone is already set');
105+
}
106+
$this->timezone = $timezone;
78107
}
79108

80109
/**
@@ -218,12 +247,12 @@ private function formatLastSyncData($packagesForInstall, $lastSyncData)
218247
private function formatSyncDate($syncDate)
219248
{
220249
return [
221-
'date' => $this->timezone->formatDateTime(
250+
'date' => $this->getTimezone()->formatDateTime(
222251
new \DateTime('@'.$syncDate),
223252
\IntlDateFormatter::MEDIUM,
224253
\IntlDateFormatter::NONE
225254
),
226-
'time' => $this->timezone->formatDateTime(
255+
'time' => $this->getTimezone()->formatDateTime(
227256
new \DateTime('@'.$syncDate),
228257
\IntlDateFormatter::NONE,
229258
\IntlDateFormatter::MEDIUM

setup/src/Magento/Setup/Model/ConfigGenerator.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,23 @@ public function __construct(Random $random, DeploymentConfig $deploymentConfig)
6161
$this->deploymentConfig = $deploymentConfig;
6262
}
6363

64+
/**
65+
* Creates install segment config data
66+
*
67+
* @deprecated
68+
*
69+
* @return ConfigData
70+
*/
71+
public function createInstallConfig()
72+
{
73+
$configData = new ConfigData(ConfigFilePool::APP_ENV);
74+
75+
if ($this->deploymentConfig->get(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE) === null) {
76+
$configData->set(ConfigOptionsListConstants::CONFIG_PATH_INSTALL_DATE, date('r'));
77+
}
78+
return $configData;
79+
}
80+
6481
/**
6582
* Creates encryption key config data
6683
* @param array $data

setup/src/Magento/Setup/Model/Installer.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,24 @@ private function deleteDeploymentConfig()
11111111
}
11121112
}
11131113

1114+
/**
1115+
* Validates that deployment configuration exists
1116+
*
1117+
* @deprecated
1118+
*
1119+
* @throws \Magento\Setup\Exception
1120+
* @return void
1121+
*/
1122+
private function assertDeploymentConfigExists()
1123+
{
1124+
if (!$this->deploymentConfig->isAvailable()) {
1125+
throw new \Magento\Setup\Exception(
1126+
"Can't run this operation: deployment configuration is absent."
1127+
. " Run 'magento setup:config:set --help' for options."
1128+
);
1129+
}
1130+
}
1131+
11141132
/**
11151133
* Validates that MySQL is accessible and MySQL version is supported
11161134
*

setup/src/Magento/Setup/Model/UpdatePackagesCache.php

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Magento\Framework\App\Filesystem\DirectoryList;
1212
use Magento\Framework\Filesystem;
1313
use Magento\Framework\Composer\MagentoComposerApplicationFactory;
14+
use Magento\Framework\ObjectManagerInterface;
1415

1516
/**
1617
* Class UpdatePackagesCache manages information about available for update packages though the cache file.
@@ -51,13 +52,19 @@ class UpdatePackagesCache
5152
*/
5253
private $pathToCacheFile = 'update_composer_packages.json';
5354

55+
/**
56+
* @var ObjectManagerInterface
57+
*/
58+
private $objectManager;
59+
5460
/**
5561
* Constructor
5662
*
5763
* @param MagentoComposerApplicationFactory $applicationFactory
5864
* @param \Magento\Framework\Filesystem $filesystem
5965
* @param ComposerInformation $composerInformation
6066
* @param ObjectManagerProvider $objectManagerProvider
67+
* @throws \Exception
6168
*/
6269
public function __construct(
6370
MagentoComposerApplicationFactory $applicationFactory,
@@ -67,11 +74,39 @@ public function __construct(
6774
) {
6875
$this->application = $applicationFactory->create();
6976
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
77+
$this->objectManager = $objectManagerProvider->get();
7078
$this->dateTime = $objectManagerProvider->get()
7179
->get('Magento\Setup\Model\DateTime\DateTimeProvider')->get();
7280
$this->composerInformation = $composerInformation;
7381
}
7482

83+
/**
84+
* Get datetime
85+
*
86+
* @return \Magento\Framework\Stdlib\DateTime\DateTime
87+
*/
88+
private function getDateTime()
89+
{
90+
if ($this->dateTime === null) {
91+
$this->dateTime = $this->objectManager->get('Magento\Setup\Model\DateTime\DateTimeProvider')->get();
92+
}
93+
return $this->dateTime;
94+
}
95+
96+
/**
97+
* Set datetime
98+
*
99+
* @param \Magento\Framework\Stdlib\DateTime\DateTime $dateTime
100+
* @throws \Exception
101+
*/
102+
public function setDateTime(\Magento\Framework\Stdlib\DateTime\DateTime $dateTime)
103+
{
104+
if ($this->dateTime !== null) {
105+
throw new \Exception('dateTime is already set');
106+
}
107+
$this->dateTime = $dateTime;
108+
}
109+
75110
/**
76111
* Sync and cache list of available for update versions for packages
77112
*
@@ -172,7 +207,7 @@ private function getPackageAvailableVersions($package)
172207
private function savePackagesForUpdateToCache($availableVersions)
173208
{
174209
$syncInfo = [];
175-
$syncInfo['lastSyncDate'] = $this->dateTime->gmtTimestamp();
210+
$syncInfo['lastSyncDate'] = $this->getDateTime()->gmtTimestamp();
176211
$syncInfo['packages'] = $availableVersions;
177212
$data = json_encode($syncInfo, JSON_UNESCAPED_SLASHES);
178213
try {

setup/src/Magento/Setup/Test/Unit/Controller/ComponentGridTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ public function setUp()
170170
$this->composerInformationMock,
171171
$objectManagerProvider,
172172
$this->updatePackagesCacheMock,
173-
$this->marketplaceManagerMock,
174-
$timezoneProviderMock
173+
$this->marketplaceManagerMock
175174
);
175+
$this->controller->setTimezone($timezoneProviderMock->get());
176176
}
177177

178178
public function testIndexAction()

setup/src/Magento/Setup/Test/Unit/Module/ConfigGeneratorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ public function testCreateCryptConfigWithoutInput()
4040
$this->assertEquals(['crypt' => ['key' => md5('key')]], $returnValue->getData());
4141
}
4242

43+
/**
44+
* @deprecated
45+
*/
46+
public function testCreateInstallConfig()
47+
{
48+
$returnValue = $this->configGeneratorObject->createInstallConfig([]);
49+
$this->assertInstanceOf('Magento\Framework\Config\Data\ConfigData', $returnValue);
50+
$this->assertEquals(ConfigFilePool::APP_ENV, $returnValue->getFileKey());
51+
}
52+
4353
public function testCreateSessionConfigWithInput()
4454
{
4555
$testData = [ConfigOptionsListConstants::INPUT_KEY_SESSION_SAVE => 'files'];

0 commit comments

Comments
 (0)