Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
disable
0.00% covered (danger)
0.00%
0 / 23
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 configure
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 14
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*/
13namespace phpbb\console\command\extension;
14
15use Symfony\Component\Console\Command\Command as symfony_command;
16use Symfony\Component\Console\Input\InputArgument;
17use Symfony\Component\Console\Input\InputInterface;
18use Symfony\Component\Console\Output\OutputInterface;
19use Symfony\Component\Console\Style\SymfonyStyle;
20
21class disable extends command
22{
23    /**
24     * {@inheritdoc}
25     */
26    protected function configure()
27    {
28        $this
29            ->setName('extension:disable')
30            ->setDescription($this->user->lang('CLI_DESCRIPTION_DISABLE_EXTENSION'))
31            ->addArgument(
32                'extension-name',
33                InputArgument::REQUIRED,
34                $this->user->lang('CLI_EXTENSION_NAME')
35            )
36        ;
37    }
38
39    /**
40     * Executes the command extension:disable.
41     *
42     * Disables the specified extension
43     *
44     * @param InputInterface  $input  An InputInterface instance
45     * @param OutputInterface $output An OutputInterface instance
46     *
47     * @return int
48     */
49    protected function execute(InputInterface $input, OutputInterface $output)
50    {
51        $io = new SymfonyStyle($input, $output);
52
53        $name = $input->getArgument('extension-name');
54
55        if (!$this->manager->is_enabled($name))
56        {
57            $io->error($this->user->lang('CLI_EXTENSION_DISABLED', $name));
58            return 2;
59        }
60
61        $this->manager->disable($name);
62        $this->manager->load_extensions();
63
64        if ($this->manager->is_enabled($name))
65        {
66            $io->error($this->user->lang('CLI_EXTENSION_DISABLE_FAILURE', $name));
67            return symfony_command::FAILURE;
68        }
69        else
70        {
71            $this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_DISABLE', time(), array($name));
72            $this->check_apcu_cache($io);
73            $io->success($this->user->lang('CLI_EXTENSION_DISABLE_SUCCESS', $name));
74            return symfony_command::SUCCESS;
75        }
76    }
77}