diff --git a/src/MagentoHackathon/Composer/Magento/Plugin.php b/src/MagentoHackathon/Composer/Magento/Plugin.php index 93125bb7..ec845f72 100644 --- a/src/MagentoHackathon/Composer/Magento/Plugin.php +++ b/src/MagentoHackathon/Composer/Magento/Plugin.php @@ -129,6 +129,7 @@ public function onPackageUnistall(\Composer\Installer\PackageEvent $event) $deployStrategy = $this->installer->getDeployStrategy($package); $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $libPath); $deployStrategy->rmdirRecursive($packageInstallationPath . $ds . $magentoPackagePath); + $this->requestRegeneration(); } /** @@ -155,10 +156,7 @@ public function onNewCodeEvent(\Composer\Script\Event $event) $this->deployManager->doDeploy(); $this->deployLibraries(); $this->saveVendorDirPath($event->getComposer()); - if (file_exists($this->installer->getTargetDir() . $this->varFolder)) { - $filename = $this->installer->getTargetDir() . $this->varFolder . $this->regenerate; - touch($filename); - } + $this->requestRegeneration(); } @@ -281,4 +279,17 @@ private function saveVendorDirPath(Composer $composer) AUTOLOAD; file_put_contents($vendorPathFile, $content); } + + /** + * Force regeneration of var/di, var/cache, var/generation on next object manager invocation + * + * @return void + */ + private function requestRegeneration() + { + if (is_writable($this->installer->getTargetDir() . $this->varFolder)) { + $filename = $this->installer->getTargetDir() . $this->varFolder . $this->regenerate; + touch($filename); + } + } }