/**
  * 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 function onPostPackageUninstall(PackageEvent $event)
 {
     if (!$event->isDevMode()) {
         // Do nothing in production mode.
         return;
     }
     $options = (new ConfigDiscovery())->getAvailableConfigOptions(array_keys($this->packageTypes), $this->projectRoot);
     if (empty($options)) {
         // No configuration options found; do nothing.
         return;
     }
     $package = $event->getOperation()->getPackage();
     $name = $package->getName();
     $extra = $this->getExtraMetadata($package->getExtra());
     $this->removePackageFromConfig($name, $extra, $options);
 }
 /**
  * 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);
     }
 }