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