24
24
*/
25
25
class Files
26
26
{
27
- /**
28
- * Include app code
29
- */
30
27
const INCLUDE_APP_CODE = 1 ;
31
28
32
- /**
33
- * Include tests
34
- */
35
29
const INCLUDE_TESTS = 2 ;
36
30
37
- /**
38
- * Include dev tools
39
- */
40
31
const INCLUDE_DEV_TOOLS = 4 ;
41
32
42
- /**
43
- * Include templates
44
- */
45
33
const INCLUDE_TEMPLATES = 8 ;
46
34
47
- /**
48
- * Include lib files
49
- */
50
35
const INCLUDE_LIBS = 16 ;
51
36
52
- /**
53
- * Include pub code
54
- */
55
37
const INCLUDE_PUB_CODE = 32 ;
56
38
57
- /**
58
- * Include non classes
59
- */
60
39
const INCLUDE_NON_CLASSES = 64 ;
61
40
62
- /**
63
- * Include setup
64
- */
65
41
const INCLUDE_SETUP = 128 ;
66
42
67
43
/**
@@ -395,11 +371,11 @@ public function getMainConfigFiles($asDataSet = true)
395
371
}
396
372
$ globPaths = [BP . '/app/etc/config.xml ' , BP . '/app/etc/*/config.xml ' ];
397
373
$ configXmlPaths = array_merge ($ globPaths , $ configXmlPaths );
398
- $ files = [];
374
+ $ files = [[] ];
399
375
foreach ($ configXmlPaths as $ xmlPath ) {
400
- $ files = array_merge ( $ files , glob ($ xmlPath , GLOB_NOSORT ) );
376
+ $ files[] = glob ($ xmlPath , GLOB_NOSORT );
401
377
}
402
- self ::$ _cache [$ cacheKey ] = $ files ;
378
+ self ::$ _cache [$ cacheKey ] = array_merge (... $ files) ;
403
379
}
404
380
if ($ asDataSet ) {
405
381
return self ::composeDataSets (self ::$ _cache [$ cacheKey ]);
@@ -679,6 +655,7 @@ private function collectModuleLayoutFiles(array $params, $location)
679
655
}
680
656
}
681
657
} else {
658
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
682
659
$ files = array_merge ($ files , $ moduleFiles );
683
660
}
684
661
}
@@ -713,8 +690,10 @@ private function collectThemeLayoutFiles(array $params, $location)
713
690
);
714
691
715
692
if ($ params ['with_metainfo ' ]) {
693
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
716
694
$ files = array_merge ($ this ->parseThemeFiles ($ themeFiles , $ currentThemePath , $ theme ));
717
695
} else {
696
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
718
697
$ files = array_merge ($ files , $ themeFiles );
719
698
}
720
699
}
@@ -925,14 +904,12 @@ public function getStaticPreProcessingFiles($filePattern = '*')
925
904
$ area = '* ' ;
926
905
$ locale = '* ' ;
927
906
$ result = [];
928
- $ moduleWebPath = [];
929
907
$ moduleLocalePath = [];
930
908
foreach ($ this ->componentRegistrar ->getPaths (ComponentRegistrar::MODULE ) as $ moduleDir ) {
931
- $ moduleWebPath [] = $ moduleDir . "/view/ {$ area }/web " ;
932
909
$ moduleLocalePath [] = $ moduleDir . "/view/ {$ area }/web/i18n/ {$ locale }" ;
933
910
}
934
911
935
- $ this ->_accumulateFilesByPatterns ( $ moduleWebPath , $ filePattern , $ result, ' _parseModuleStatic ' );
912
+ $ this ->accumulateStaticFiles ( $ area , $ filePattern , $ result );
936
913
$ this ->_accumulateFilesByPatterns ($ moduleLocalePath , $ filePattern , $ result , '_parseModuleLocaleStatic ' );
937
914
$ this ->accumulateThemeStaticFiles ($ area , $ locale , $ filePattern , $ result );
938
915
self ::$ _cache [$ key ] = $ result ;
@@ -1043,6 +1020,8 @@ protected function _accumulateFilesByPatterns(array $patterns, $filePattern, arr
1043
1020
/**
1044
1021
* Parse meta-info of a static file in module
1045
1022
*
1023
+ * @deprecated Replaced with method accumulateStaticFiles()
1024
+ *
1046
1025
* @param string $file
1047
1026
* @return array
1048
1027
*/
@@ -1062,6 +1041,29 @@ protected function _parseModuleStatic($file)
1062
1041
return [];
1063
1042
}
1064
1043
1044
+ /**
1045
+ * Search static files from all modules by the specified pattern and accumulate meta-info
1046
+ *
1047
+ * @param string $area
1048
+ * @param string $filePattern
1049
+ * @param array $result
1050
+ * @return void
1051
+ */
1052
+ private function accumulateStaticFiles ($ area , $ filePattern , array &$ result )
1053
+ {
1054
+ foreach ($ this ->componentRegistrar ->getPaths (ComponentRegistrar::MODULE ) as $ moduleName => $ moduleDir ) {
1055
+ $ moduleWebPath = $ moduleDir . "/view/ {$ area }/web " ;
1056
+
1057
+ foreach (self ::getFiles ([$ moduleWebPath ], $ filePattern ) as $ absolutePath ) {
1058
+ $ localPath = substr ($ absolutePath , strlen ($ moduleDir ) + 1 );
1059
+ if (preg_match ('/^view\/([a-z]+)\/web\/(.+)$/i ' , $ localPath , $ matches ) === 1 ) {
1060
+ list (, $ parsedArea , $ parsedPath ) = $ matches ;
1061
+ $ result [] = [$ parsedArea , '' , '' , $ moduleName , $ parsedPath , $ absolutePath ];
1062
+ }
1063
+ }
1064
+ }
1065
+ }
1066
+
1065
1067
/**
1066
1068
* Parse meta-info of a localized (translated) static file in module
1067
1069
*
0 commit comments