/** * Deletes the App using ProcessComposerHelper * * @throws \Exception * @throws yii\base\Exception */ public function deleteApp() { try { if (FactoryCommandHelper::composer()->check()) { FactoryCommandHelper::composer()->execute($this->composerPackage, 'down'); } } catch (yii\base\Exception $e) { throw $e; } }
/** * Decides which module handler type to use for CRUD the Apps * Right now we only support Composer handlers. * * @param array $appData * @return ComposerAppHandler|null * @throws \Exception */ protected function getInstallationHandler($appData) { // 1 Check if system has to install the App via the official installation system (composer) // or another one (right now we only support composer installations). $installationHandler = NULL; if (FactoryCommandHelper::composer()->check()) { /** @var ComposerAppHandler $installationHandler */ $installationHandler = new ComposerAppHandler($appData); } else { throw new \Exception('Only composer installation supported right now.'); } return $installationHandler; }
/** * Executes the composer callings that the App may have in case it is a * composer module. * * If so, it will install all the packages that holds in the getComposerPackageData method. * */ protected function executeComposer() { if (method_exists($this->module, 'getComposerPackageData') && FactoryCommandHelper::composer()->check()) { $package = $this->module->getComposerPackageData(); if (is_null($package)) { return; } elseif (!is_array($package)) { $package = [$package]; } foreach ($package as $p) { FactoryCommandHelper::composer()->execute($p, $this->preMethod); } // Now we will load the brand new aliases into the system to be able to use // the new packages installed in this system. $file = Yii::$app->getVendorPath() . '/yiisoft/extensions.php'; if (!is_file($file)) { return []; } // invalidate opcache of extensions.php if exists if (function_exists('opcache_invalidate')) { opcache_invalidate($file, TRUE); } $extensions = (require $file); foreach ($package as $p) { $p = explode(':', $p)[0]; if (array_key_exists($p, $extensions)) { $aliasList = $extensions[$p]['alias']; Yii::$app->setAliases($aliasList); } } } }