Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
recreate
0.00% covered (danger)
0.00%
0 / 19
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 / 2
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 / 13
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\thumbnail;
14
15use phpbb\language\language;
16use phpbb\user;
17use Symfony\Component\Console\Command\Command as symfony_command;
18use Symfony\Component\Console\Input\InputInterface;
19use Symfony\Component\Console\Input\ArrayInput;
20use Symfony\Component\Console\Output\OutputInterface;
21
22class recreate extends \phpbb\console\command\command
23{
24    /**
25     * @var language
26     */
27    protected $language;
28
29    /**
30     * Constructor
31     *
32     * @param user $user User
33     * @param language $language Language
34     */
35    public function __construct(user $user, language $language)
36    {
37        $this->language = $language;
38
39        parent::__construct($user);
40    }
41
42    /**
43    * Sets the command name and description
44    *
45    * @return void
46    */
47    protected function configure()
48    {
49        $this
50            ->setName('thumbnail:recreate')
51            ->setDescription($this->language->lang('CLI_DESCRIPTION_THUMBNAIL_RECREATE'))
52        ;
53    }
54
55    /**
56    * Executes the command thumbnail:recreate.
57    *
58    * This command is a "macro" to execute thumbnail:delete and then thumbnail:generate.
59    *
60    * @param InputInterface $input The input stream used to get the argument and verboe option.
61    * @param OutputInterface $output The output stream, used for printing verbose-mode and error information.
62    *
63    * @return int 0 if all is ok, 1 if a thumbnail couldn't be deleted.
64    */
65    protected function execute(InputInterface $input, OutputInterface $output): int
66    {
67        $command = $this->getApplication()->find('thumbnail:delete');
68
69        $parameters = [];
70
71        if ($input->getOption('verbose'))
72        {
73            $parameters['-' . str_repeat('v', $output->getVerbosity() - 1)] = true;
74        }
75
76        $this->getApplication()->setAutoExit(false);
77
78        $input_delete = new ArrayInput($parameters);
79        $return = $command->run($input_delete, $output);
80
81        if ($return === symfony_command::SUCCESS)
82        {
83            $command = $this->getApplication()->find('thumbnail:generate');
84
85            $input_create = new ArrayInput([]);
86            $return = $command->run($input_create, $output);
87        }
88
89        $this->getApplication()->setAutoExit(true);
90
91        return $return;
92    }
93}