N°2982 - PR reviews

This commit is contained in:
odain
2021-04-16 11:46:14 +02:00
parent 65d94bd914
commit 135b5e8adb
4 changed files with 9 additions and 9 deletions

View File

@@ -1399,7 +1399,7 @@ class Config
'source_of_value' => '',
'show_in_conf_sample' => true,
],
'theme_precompilation_enabled' => [
'theme.enable_precompilation' => [
'type' => 'bool',
'description' => 'If false, theme compilation will not use any precompiled file setup optimization.)',
'default' => true,

View File

@@ -2911,13 +2911,13 @@ EOF;
$bHasCompiled = static::$oThemeHandlerService->CompileTheme($sThemeId, true, $this->sCompilationTimeStamp, $aThemeParameters, $aImportsPaths, $sTempTargetDir);
if ($bHasCompiled) {
if (utils::GetConfig()->Get('theme_precompilation_enabled')){
if (utils::GetConfig()->Get('theme.enable_precompilation')){
if (utils::IsDevelopmentEnvironment() && ! empty(trim($sPrecompiledStylesheet)))
{ //help developers to detect & push theme precompilation changes
$sInitialPrecompiledFilePath = null;
$aRootDirs = $this->oFactory->getRootDirs();
$aRootDirs = $this->oFactory->GetRootDirs();
if (is_array($aRootDirs) && count($aRootDirs) !== 0) {
foreach ($this->oFactory->getRootDirs() as $sRootDir) {
foreach ($this->oFactory->GetRootDirs() as $sRootDir) {
$sCurrentFile = $sRootDir. DIRECTORY_SEPARATOR . $sPrecompiledStylesheet;
if (is_file($sCurrentFile) && is_writable($sCurrentFile)) {
$sInitialPrecompiledFilePath = $sCurrentFile;
@@ -2942,7 +2942,7 @@ EOF;
$this->Log(sprintf('Themes compilation took: %.3f ms for %d themes.', (microtime(true) - $fStart)*1000.0, count($aThemes)));
}
public static function setThemeHandlerService(ThemeHandlerService $oThemeHandlerService): void {
public static function SetThemeHandlerService(ThemeHandlerService $oThemeHandlerService): void {
self::$oThemeHandlerService = $oThemeHandlerService;
}
@@ -2957,7 +2957,7 @@ EOF;
* @return string : file path of latest precompiled file to use for setup
*/
public function UseLatestPrecompiledFile(string $sTempTargetDir, string $sPrecompiledFileUri, $sPostCompilationLatestPrecompiledFile, $sThemeId) : ?string {
if (! utils::GetConfig()->Get('theme_precompilation_enabled')) {
if (! utils::GetConfig()->Get('theme.enable_precompilation')) {
return null;
}

View File

@@ -1838,7 +1838,7 @@ EOF;
/**
* @return mixed
*/
public function getRootDirs() {
public function GetRootDirs() {
return $this->aRootDirs;
}
}

View File

@@ -115,7 +115,7 @@ class MFCompilerTest extends ItopTestCase {
*/
public function testUseLatestPrecompiledFile(string $sTempTargetDir, string $sPrecompiledFileUri, string $sPostCompilationLatestPrecompiledFile, string $sThemeDir, ?string $sExpectedReturn, bool $bDisableThemePrecompilationViaConf = false){
if ($bDisableThemePrecompilationViaConf){
utils::GetConfig()->Set('theme_precompilation_enabled', false);
utils::GetConfig()->Set('theme.enable_precompilation', false);
}
$sRes = $this->oMFCompiler->UseLatestPrecompiledFile($sTempTargetDir, $sPrecompiledFileUri, $sPostCompilationLatestPrecompiledFile, $sThemeDir);
$this->assertEquals($sExpectedReturn, $sRes);
@@ -186,7 +186,7 @@ class MFCompilerTest extends ItopTestCase {
//CompileTheme($sThemeId, $bSetup = false, $sSetupCompilationTimestamp="", $aThemeParameters = null, $aImportsPaths = null, $sWorkingPath = null)
MFCompiler::setThemeHandlerService($oThemeHandlerService);
MFCompiler::SetThemeHandlerService($oThemeHandlerService);
$this->oMFCompiler->CompileThemes($oBrandingNode, $this->sTmpDir);
}
}