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