コード例 #1
0
ファイル: Helper.php プロジェクト: podvincev-n/yii2-app-base
 /**
  * Вызов инсталлятора из composer
  * @param PackageEvent $event
  * @return type
  */
 public static function package(PackageEvent $event)
 {
     // консоль
     $io = $event->getIO();
     // устанавливаемый модуль
     $package = $event->getOperation()->getPackage();
     // только для модулей /podvincev-n/
     if (preg_match('#podvincev-n/([^/]+)#', $package->getName(), $match)) {
         $packageName = $match[1];
     } else {
         $io->write("> skip install " . $package->getName() . ": not /podvincev-n/", true);
         return false;
     }
     $composer = $event->getComposer();
     $composerConfig = $composer->getConfig();
     $installationManager = $composer->getInstallationManager();
     $installationPath = $installationManager->getInstallPath($package);
     $installationFile = $installationPath . '/Install.php';
     $basePath = dirname($composerConfig->get('vendor-dir'));
     if (file_exists($installationFile)) {
         $io->write("> installation file: " . $installationFile, true);
         $installerClass = (require_once $installationFile);
         $installer = new $installerClass(array('yiiConsoleApp' => self::getYiiConsoleApp($basePath), 'path' => $installationPath, 'name' => $packageName, 'io' => $io, 'migrationPath' => static::getMigrationPath($basePath), 'configPath' => static::getYiipConfigPath($basePath) . $packageName));
         $installer->install();
         $io->write("---", true);
         $io->write("", true);
     } else {
         $io->write("> no installation file", true);
         $io->write("", true);
     }
     return true;
 }
コード例 #2
0
 function after(PackageEvent $event)
 {
     $io = $event->getIO();
     $package = $this->getPackage($event, $io);
     $packageName = $package->getName();
     $packageType = $package->getType();
     list($packageDrupal) = explode('-', $packageType);
     if ($packageName === 'drupal/drupal') {
         $this->afterDrupalRestoreCustom($event, $io);
     } elseif ($packageDrupal === 'drupal') {
         $this->afterDrupalRewriteInfo($event, $io, $package);
     }
     if ($packageDrupal === 'drupal' && $this->noGitDir) {
         $this->afterDrupalRemoveGitDir($event, $io, $package);
     }
 }
コード例 #3
0
 /**
  * post-package-uninstall event hook
  *
  * This routine exits early if any of the following conditions apply:
  *
  * - Executed in non-development mode
  * - No config/application.config.php is available
  * - The composer.json does not define one of either extra.zf.component
  *   or extra.zf.module
  * - The value used for either extra.zf.component or extra.zf.module are
  *   empty or not strings.
  *
  * Otherwise, it will attempt to update the application configuration
  * using the value(s) discovered in extra.zf.component and/or extra.zf.module,
  * removing their values from the `modules` list.
  *
  * @param PackageEvent $event
  * @return void
  */
 public static function postPackageUninstall(PackageEvent $event)
 {
     if (!$event->isDevMode()) {
         // Do nothing in production mode.
         return;
     }
     if (!is_file('config/application.config.php')) {
         // Do nothing if config/application.config.php does not exist
         return;
     }
     $package = $event->getOperation()->getPackage();
     $name = $package->getName();
     $extra = self::getExtraMetadata($package->getExtra());
     $io = $event->getIO();
     if (isset($extra['module']) && is_string($extra['module']) && !empty($extra['module'])) {
         $io->write(sprintf('<info>Uninstalling module %s (from package %s)</info>', $extra['module'], $name));
         self::removeModuleFromApplicationConfig($extra['module'], $io);
     }
     if (isset($extra['component']) && is_string($extra['component']) && !empty($extra['component'])) {
         $io->write(sprintf('<info>Uninstalling component module %s (from package %s)</info>', $extra['component'], $name));
         self::removeModuleFromApplicationConfig($extra['component'], $io);
     }
 }
コード例 #4
0
ファイル: FixtureManager.php プロジェクト: mothership-ec/cog
 /**
  * Detects changes to config fixtures in the newly updated version of a
  * given package. Also installs any new configs fixtures not in this
  * installations config directory.
  *
  * The user is warned if a difference is detected, as they should manually
  * check to see what has changed.
  *
  * @param  PackageEvent $event The post-update package event
  *
  * @return void|false          Returns false if the method needn't run
  */
 public static function postUpdate(PackageEvent $event)
 {
     if (!static::isPackageCompatible($event->getOperation()->getInitialPackage())) {
         return false;
     }
     $package = $event->getOperation()->getInitialPackage();
     $fixtureDir = static::getConfigFixtureDir($event->getComposer(), $package);
     $workingDir = static::getWorkingDir();
     try {
         $fixtures = static::getFixtures($fixtureDir);
         if (!$fixtures) {
             return false;
         }
         foreach ($fixtures as $fixture) {
             $file = $workingDir . 'config/' . $fixture;
             $packageName = $event->getOperation()->getInitialPackage()->getPrettyName();
             // If config file for this fixture exists, detect + report any change in the fixture
             if (file_exists($file)) {
                 $checksum = md5_file($fixtureDir . $fixture);
                 if (isset(static::$_updatedFixtures[$package->getPrettyName()][$fixture]) && $checksum !== static::$_updatedFixtures[$package->getPrettyName()][$fixture]) {
                     $event->getIO()->write(sprintf('<warning>Package `%s` config fixture `%s` has changed: please review manually.</warning>', $package->getPrettyName(), $fixture));
                 }
             } else {
                 copy($fixtureDir . $fixture, $file);
                 $event->getIO()->write(sprintf('<info>Moved package `%s` config fixture `%s` to application config directory.</info>', $packageName, $fixture));
             }
         }
     } catch (Exception $e) {
         $event->getIO()->write('<error>' . $e->getMessage() . '</error>');
     }
 }