|
| 1 | +<?php |
| 2 | +/** |
| 3 | +* |
| 4 | +* @package phpBB3 |
| 5 | +* @copyright (c) 2013 phpBB Group |
| 6 | +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
| 7 | +* |
| 8 | +*/ |
| 9 | +namespace phpbb\console\command\extension; |
| 10 | + |
| 11 | +use Symfony\Component\Console\Input\InputInterface; |
| 12 | +use Symfony\Component\Console\Output\OutputInterface; |
| 13 | + |
| 14 | +class show extends command |
| 15 | +{ |
| 16 | + protected function configure() |
| 17 | + { |
| 18 | + $this |
| 19 | + ->setName('extension:show') |
| 20 | + ->setDescription('Lists all extensions in the database and on the filesystem.') |
| 21 | + ; |
| 22 | + } |
| 23 | + |
| 24 | + protected function execute(InputInterface $input, OutputInterface $output) |
| 25 | + { |
| 26 | + $this->manager->load_extensions(); |
| 27 | + $all = array_keys($this->manager->all_available()); |
| 28 | + |
| 29 | + if (empty($all)) |
| 30 | + { |
| 31 | + $output->writeln('<comment>No extensions were found.</comment>'); |
| 32 | + return 3; |
| 33 | + } |
| 34 | + |
| 35 | + $enabled = array_keys($this->manager->all_enabled()); |
| 36 | + $this->print_extension_list($output, 'Enabled', $enabled); |
| 37 | + |
| 38 | + $output->writeln(''); |
| 39 | + |
| 40 | + $disabled = array_keys($this->manager->all_disabled()); |
| 41 | + $this->print_extension_list($output, 'Disabled', $disabled); |
| 42 | + |
| 43 | + $output->writeln(''); |
| 44 | + |
| 45 | + $purged = array_diff($all, $enabled, $disabled); |
| 46 | + $this->print_extension_list($output, 'Available', $purged); |
| 47 | + } |
| 48 | + |
| 49 | + protected function print_extension_list(OutputInterface $output, $type, array $extensions) |
| 50 | + { |
| 51 | + $output->writeln("<info>$type:</info>"); |
| 52 | + |
| 53 | + foreach ($extensions as $extension) |
| 54 | + { |
| 55 | + $output->writeln(" - $extension"); |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments