@@ -57,36 +57,7 @@ public function regenerate()
5757 $ configPool = new ConfigFilePool ();
5858 $ envPath = $ deploymentConfig . '/ ' . $ configPool ->getPath (ConfigFilePool::APP_ENV );
5959 if ($ this ->write ->isExist ($ this ->write ->getRelativePath ($ envPath ))) {
60- $ cacheData = include $ envPath ;
61-
62- if (isset ($ cacheData ['cache_types ' ])) {
63- $ enabledCacheTypes = $ cacheData ['cache_types ' ];
64- $ enabledCacheTypes = array_filter ($ enabledCacheTypes , function ($ value ) {
65- return $ value ;
66- }
67- );
68- if (!empty ($ enabledCacheTypes )) {
69- $ this ->write ->writeFile ($ this ->write ->getRelativePath (
70- $ this ->directoryList ->getPath (DirectoryList::VAR_DIR )) . '/.cachestates.json ' ,
71- json_encode ($ enabledCacheTypes )
72- );
73- $ cacheTypes = array_keys ($ cacheData ['cache_types ' ]);
74-
75- foreach ($ cacheTypes as $ cacheType ) {
76- $ cacheData ['cache_types ' ][$ cacheType ] = 0 ;
77- }
78-
79- $ formatter = new PhpFormatter ();
80- $ contents = $ formatter ->format ($ cacheData );
81-
82- $ this ->write ->writeFile ($ this ->write ->getRelativePath ($ envPath ), $ contents );
83- if (function_exists ('opcache_invalidate ' )) {
84- opcache_invalidate (
85- $ this ->write ->getAbsolutePath ($ envPath )
86- );
87- }
88- }
89- }
60+ $ this ->saveCacheStatus ($ envPath );
9061 }
9162 $ cachePath = $ this ->write ->getRelativePath ($ this ->directoryList ->getPath (DirectoryList::CACHE ));
9263 $ generationPath = $ this ->write ->getRelativePath ($ this ->directoryList ->getPath (DirectoryList::GENERATION ));
@@ -107,6 +78,44 @@ public function regenerate()
10778 }
10879 }
10980
81+ /**
82+ * Read Cache types from env.php and write to a json file.
83+ *
84+ * @param $envPath
85+ */
86+ private function saveCacheStatus ($ envPath )
87+ {
88+ $ cacheData = include $ envPath ;
89+
90+ if (isset ($ cacheData ['cache_types ' ])) {
91+ $ enabledCacheTypes = $ cacheData ['cache_types ' ];
92+ $ enabledCacheTypes = array_filter ($ enabledCacheTypes , function ($ value ) {
93+ return $ value ;
94+ });
95+ if (!empty ($ enabledCacheTypes )) {
96+ $ this ->write ->writeFile ($ this ->write ->getRelativePath (
97+ $ this ->directoryList ->getPath (DirectoryList::VAR_DIR )
98+ ) . '/.cachestates.json ' ,
99+ json_encode ($ enabledCacheTypes )
100+ );
101+ $ cacheTypes = array_keys ($ cacheData ['cache_types ' ]);
102+
103+ foreach ($ cacheTypes as $ cacheType ) {
104+ $ cacheData ['cache_types ' ][$ cacheType ] = 0 ;
105+ }
106+
107+ $ formatter = new PhpFormatter ();
108+ $ contents = $ formatter ->format ($ cacheData );
109+
110+ $ this ->write ->writeFile ($ this ->write ->getRelativePath ($ envPath ), $ contents );
111+ if (function_exists ('opcache_invalidate ' )) {
112+ opcache_invalidate (
113+ $ this ->write ->getAbsolutePath ($ envPath )
114+ );
115+ }
116+ }
117+ }
118+ }
110119 /**
111120 * Create flag for regeneration of code and di
112121 *
0 commit comments