Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
list_available
0.00% covered (danger)
0.00%
0 / 14
0.00% covered (danger)
0.00%
0 / 3
30
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
 configure
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2/**
3*
4* This file is part of the phpBB Forum Software package.
5*
6* @copyright (c) phpBB Limited <https://www.phpbb.com>
7* @license GNU General Public License, version 2 (GPL-2.0)
8*
9* For full copyright and license information, please see
10* the docs/CREDITS.txt file.
11*
12*/
13
14namespace phpbb\console\command\extension;
15
16use phpbb\composer\manager_interface;
17use Symfony\Component\Console\Command\Command as symfony_command;
18use Symfony\Component\Console\Input\InputInterface;
19use Symfony\Component\Console\Output\OutputInterface;
20use Symfony\Component\Console\Style\SymfonyStyle;
21
22class list_available extends \phpbb\console\command\command
23{
24    /**
25     * @var manager_interface Composer extensions manager
26     */
27    protected $manager;
28
29    public function __construct(\phpbb\user $user, manager_interface $manager)
30    {
31        $this->manager = $manager;
32
33        $user->add_lang('acp/extensions');
34
35        parent::__construct($user);
36    }
37
38    /**
39    * Sets the command name and description
40    *
41    * @return void
42    */
43    protected function configure()
44    {
45        $this
46            ->setName('extension:list-available')
47            ->setDescription($this->user->lang('CLI_DESCRIPTION_EXTENSION_LIST_AVAILABLE'))
48        ;
49    }
50
51    /**
52    * Executes the command extension:install
53    *
54    * @param InputInterface $input
55    * @param OutputInterface $output
56    * @return int
57    */
58    protected function execute(InputInterface $input, OutputInterface $output)
59    {
60        $io = new SymfonyStyle($input, $output);
61
62        $extensions = [];
63
64        foreach ($this->manager->get_available_packages() as $package)
65        {
66            $extensions[] = '<info>' . $package['name'] . '</info> (<comment>' . $package['version'] . '</comment>) ' . $package['url'] .
67                            ($package['description'] ? "\n" . $package['description'] : '');
68        }
69
70        $io->listing($extensions);
71
72        return symfony_command::SUCCESS;
73    }
74}