Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
update
0.00% covered (danger)
0.00%
0 / 21
0.00% covered (danger)
0.00%
0 / 3
20
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 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 1
6
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\io\console_io;
17use phpbb\composer\manager_interface;
18use phpbb\language\language;
19use Symfony\Component\Console\Command\Command as symfony_command;
20use Symfony\Component\Console\Formatter\OutputFormatterStyle;
21use Symfony\Component\Console\Input\InputArgument;
22use Symfony\Component\Console\Input\InputInterface;
23use Symfony\Component\Console\Output\OutputInterface;
24use Symfony\Component\Console\Style\SymfonyStyle;
25
26class update extends \phpbb\console\command\command
27{
28    /**
29     * @var manager_interface Composer extensions manager
30     */
31    protected $manager;
32
33    /**
34     * @var language
35     */
36    protected $language;
37
38    public function __construct(\phpbb\user $user, manager_interface $manager, language $language)
39    {
40        $this->manager = $manager;
41        $this->language = $language;
42
43        parent::__construct($user);
44    }
45
46    /**
47    * Sets the command name and description
48    *
49    * @return void
50    */
51    protected function configure()
52    {
53        $this
54            ->setName('extension:update')
55            ->setDescription($this->user->lang('CLI_DESCRIPTION_EXTENSION_UPDATE'))
56            ->addArgument(
57                'extensions',
58                InputArgument::IS_ARRAY | InputArgument::REQUIRED,
59                $this->user->lang('CLI_DESCRIPTION_EXTENSION_UPDATE_ARGUMENT'))
60        ;
61    }
62
63    /**
64    * Executes the command extension:install
65    *
66    * @param InputInterface $input
67    * @param OutputInterface $output
68    * @return integer
69    */
70    protected function execute(InputInterface $input, OutputInterface $output)
71    {
72        $output->getFormatter()->setStyle('warning', new OutputFormatterStyle('black', 'yellow'));
73
74        $io = new SymfonyStyle($input, $output);
75
76        if (!$this->manager->check_requirements())
77        {
78            $io->error($this->language->lang('EXTENSIONS_COMPOSER_NOT_WRITABLE'));
79            return symfony_command::FAILURE;
80        }
81
82        $composer_io = new console_io($input, $output, $this->getHelperSet(), $this->language);
83        $extensions = $input->getArgument('extensions');
84
85        $this->manager->update($extensions, $composer_io);
86
87        $io->success($this->language->lang('EXTENSIONS_UPDATED'));
88
89        return symfony_command::SUCCESS;
90    }
91}