Skip to content

Commit 0132caf

Browse files
committed
MAGETWO-47999: [Github] Added theme is not registered during production mode
- introducing recurringData, same as schema but for data. - registers theme in db when update is executed.
1 parent 503245f commit 0132caf

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

app/code/Magento/Theme/Model/Theme/Registration.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,26 @@ protected function _savePreviewImage(ThemeInterface $theme)
134134
return $this;
135135
}
136136

137+
/**
138+
* Get physical themes
139+
*
140+
* @return ThemeInterface
141+
*/
142+
public function getAllPhysicalThemes()
143+
{
144+
return $this->_themeCollection;
145+
}
146+
147+
/**
148+
* Get DB themes
149+
*
150+
* @return ThemeInterface
151+
*/
152+
public function getAllDbThemes()
153+
{
154+
return $this->_collectionFactory->create();
155+
}
156+
137157
/**
138158
* Get theme from DB by full path
139159
*
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Theme\Setup;
8+
9+
use Magento\Framework\Setup\InstallDataInterface;
10+
use Magento\Framework\Setup\ModuleContextInterface;
11+
use Magento\Framework\Setup\ModuleDataSetupInterface;
12+
use Magento\Theme\Model\Theme\Registration;
13+
14+
/**
15+
* Upgrade registered themes
16+
*/
17+
class RecurringData implements InstallDataInterface
18+
{
19+
/**
20+
* Theme registration
21+
*
22+
* @var Registration
23+
*/
24+
private $themeRegistration;
25+
26+
/**
27+
* Init
28+
*
29+
* @param Registration $themeRegistration
30+
*/
31+
public function __construct(Registration $themeRegistration)
32+
{
33+
$this->themeRegistration = $themeRegistration;
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
40+
{
41+
$dbThemes = $this->themeRegistration->getAllDbThemes()->getData();
42+
$dbThemeNames = [];
43+
foreach ($dbThemes as $dbTheme) {
44+
$dbThemeNames[] = $dbTheme['area'] . '/' . $dbTheme['code'];
45+
}
46+
47+
$filesystemThemes = $this->themeRegistration->getAllPhysicalThemes()->getItems();
48+
$filesystemThemeNames = array_keys($filesystemThemes);
49+
50+
if (sizeof(array_diff($dbThemeNames, $filesystemThemeNames)) > 0
51+
|| sizeof(array_diff($filesystemThemeNames, $dbThemeNames)) > 0) {
52+
$this->themeRegistration->register();
53+
}
54+
}
55+
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public function install($request)
321321
$script[] = ['Post installation file permissions check...', 'checkApplicationFilePermissions', []];
322322

323323
$estimatedModules = $this->createModulesConfig($request, true);
324-
$total = count($script) + 3 * count(array_filter($estimatedModules));
324+
$total = count($script) + 4 * count(array_filter($estimatedModules));
325325
$this->progress = new Installer\Progress($total, 0);
326326

327327
$this->log->log('Starting Magento installation:');
@@ -824,6 +824,17 @@ private function handleDBSchemaData($setup, $type)
824824
}
825825
$this->logProgress();
826826
}
827+
} else if ($type === 'data') {
828+
$this->log->log('Data post-updates:');
829+
foreach ($moduleNames as $moduleName) {
830+
$this->log->log("Module '{$moduleName}':");
831+
$modulePostUpdater = $this->getSchemaDataHandler($moduleName, 'data-recurring');
832+
if ($modulePostUpdater) {
833+
$this->log->logInline("Running data recurring.. ");
834+
$modulePostUpdater->install($setup, $moduleContextList[$moduleName]);
835+
}
836+
$this->logProgress();
837+
}
827838
}
828839
}
829840

@@ -1166,6 +1177,10 @@ private function getSchemaDataHandler($moduleName, $type)
11661177
$className .= '\UpgradeData';
11671178
$interface = self::DATA_UPGRADE;
11681179
break;
1180+
case 'data-recurring':
1181+
$className .= '\RecurringData';
1182+
$interface = self::DATA_INSTALL;
1183+
break;
11691184
default:
11701185
throw new \Magento\Setup\Exception("$className does not exist");
11711186
}

0 commit comments

Comments
 (0)