Exemple #1
0
 /**
  * @return int|null|void
  */
 protected function serve()
 {
     $this->gpm = new GPM();
     $packages = array_map('strtolower', $this->input->getArgument('package'));
     $this->data = ['total' => 0, 'not_found' => []];
     foreach ($packages as $package) {
         $plugin = $this->gpm->getInstalledPlugin($package);
         $theme = $this->gpm->getInstalledTheme($package);
         if ($plugin || $theme) {
             $this->data[strtolower($package)] = $plugin ?: $theme;
             $this->data['total']++;
         } else {
             $this->data['not_found'][] = $package;
         }
     }
     $this->output->writeln('');
     if (!$this->data['total']) {
         $this->output->writeln("Nothing to uninstall.");
         $this->output->writeln('');
         exit;
     }
     if (count($this->data['not_found'])) {
         $this->output->writeln("These packages were not found installed: <red>" . implode('</red>, <red>', $this->data['not_found']) . "</red>");
     }
     unset($this->data['not_found']);
     unset($this->data['total']);
     foreach ($this->data as $slug => $package) {
         $this->output->writeln("Preparing to uninstall <cyan>" . $package->name . "</cyan> [v" . $package->version . "]");
         $this->output->write("  |- Checking destination...  ");
         $checks = $this->checkDestination($slug, $package);
         if (!$checks) {
             $this->output->writeln("  '- <red>Installation failed or aborted.</red>");
             $this->output->writeln('');
         } else {
             $this->output->write("  |- Uninstalling package...  ");
             $uninstall = $this->uninstallPackage($slug, $package);
             if (!$uninstall) {
                 $this->output->writeln("  '- <red>Uninstallation failed or aborted.</red>");
                 $this->output->writeln('');
             } else {
                 $this->output->writeln("  '- <green>Success!</green>  ");
                 $this->output->writeln('');
             }
         }
     }
     // clear cache after successful upgrade
     $this->clearCache();
 }