| @@ 47-65 (lines=19) @@ | ||
| 44 | * |
|
| 45 | * @param \Buttress\Concrete\Locator\Site $site |
|
| 46 | */ |
|
| 47 | public function install(Site $site) |
|
| 48 | { |
|
| 49 | $definition = $this->getDefinition($site, 'package:install'); |
|
| 50 | $definition->parse(); |
|
| 51 | $handle = $definition->get('handle'); |
|
| 52 | ||
| 53 | if (!$handle) { |
|
| 54 | $packages = iterator_to_array($this->getAvailablePackages($site)); |
|
| 55 | if (!$packages) { |
|
| 56 | $this->cli->error('No packages available to install'); |
|
| 57 | } |
|
| 58 | ||
| 59 | $handle = $this->confirmHandle($packages); |
|
| 60 | } |
|
| 61 | ||
| 62 | $this->cli->info('Installing ' . $handle); |
|
| 63 | $this->bus->handle((new Install())->setHandle($handle)); |
|
| 64 | $this->cli->green('Installed Successfully!'); |
|
| 65 | } |
|
| 66 | ||
| 67 | /** |
|
| 68 | * Handle package:uninstall |
|
| @@ 72-90 (lines=19) @@ | ||
| 69 | * |
|
| 70 | * @param \Buttress\Concrete\Locator\Site $site |
|
| 71 | */ |
|
| 72 | public function uninstall(Site $site) |
|
| 73 | { |
|
| 74 | $definition = $this->getDefinition($site, 'package:uninstall'); |
|
| 75 | $definition->parse(); |
|
| 76 | $handle = $definition->get('handle'); |
|
| 77 | ||
| 78 | if (!$handle) { |
|
| 79 | $packages = iterator_to_array($this->getAvailablePackages($site)); |
|
| 80 | if (!$packages) { |
|
| 81 | $this->cli->error('No packages available to uninstall'); |
|
| 82 | } |
|
| 83 | ||
| 84 | $handle = $this->confirmHandle($packages); |
|
| 85 | } |
|
| 86 | ||
| 87 | $this->cli->info('Uninstalling ' . $handle); |
|
| 88 | $this->bus->handle((new Uninstall())->setHandle($handle)); |
|
| 89 | $this->cli->green('Uninstalled Successfully!'); |
|
| 90 | } |
|
| 91 | ||
| 92 | private function getDefinition(Site $site, $command) |
|
| 93 | { |
|