@@ -129,12 +129,7 @@ public function onPackageUnistall(\Composer\Installer\PackageEvent $event)
129129 $ deployStrategy = $ this ->installer ->getDeployStrategy ($ package );
130130 $ deployStrategy ->rmdirRecursive ($ packageInstallationPath . $ ds . $ libPath );
131131 $ deployStrategy ->rmdirRecursive ($ packageInstallationPath . $ ds . $ magentoPackagePath );
132-
133- // Force regeneration of var/di, var/cache, var/generation on next object manager invocation
134- if (file_exists ($ this ->installer ->getTargetDir () . $ this ->varFolder )) {
135- $ filename = $ this ->installer ->getTargetDir () . $ this ->varFolder . $ this ->regenerate ;
136- touch ($ filename );
137- }
132+ $ this ->requestRegeneration ();
138133 }
139134
140135 /**
@@ -161,12 +156,7 @@ public function onNewCodeEvent(\Composer\Script\Event $event)
161156 $ this ->deployManager ->doDeploy ();
162157 $ this ->deployLibraries ();
163158 $ this ->saveVendorDirPath ($ event ->getComposer ());
164-
165- // Force regeneration of var/di, var/cache, var/generation on next object manager invocation
166- if (file_exists ($ this ->installer ->getTargetDir () . $ this ->varFolder )) {
167- $ filename = $ this ->installer ->getTargetDir () . $ this ->varFolder . $ this ->regenerate ;
168- touch ($ filename );
169- }
159+ $ this ->requestRegeneration ();
170160 }
171161
172162
@@ -289,4 +279,17 @@ private function saveVendorDirPath(Composer $composer)
289279AUTOLOAD ;
290280 file_put_contents ($ vendorPathFile , $ content );
291281 }
282+
283+ /**
284+ * Force regeneration of var/di, var/cache, var/generation on next object manager invocation
285+ *
286+ * @return void
287+ */
288+ private function requestRegeneration ()
289+ {
290+ if (is_writable ($ this ->installer ->getTargetDir () . $ this ->varFolder )) {
291+ $ filename = $ this ->installer ->getTargetDir () . $ this ->varFolder . $ this ->regenerate ;
292+ touch ($ filename );
293+ }
294+ }
292295}
0 commit comments