aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/console/command/db/console_migrator_output_handler.php
blob: b9741a38385484ae0a6b76de9c6bb5b3a7424609 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/

namespace phpbb\console\command\db;

use phpbb\user;
use phpbb\db\migrator_output_handler_interface;
use Symfony\Component\Console\Output\OutputInterface;

class console_migrator_output_handler implements migrator_output_handler_interface
{
	/**
	 * User object.
	 *
	 * @var user
	 */
	private $user;

	/**
	 * Console output object.
	 *
	 * @var OutputInterface
	 */
	private $output;

	/**
	 * Constructor
	 *
	 * @param user				$user	User object
	 * @param OutputInterface	$output	Console output object
	 */
	public function __construct(user $user, OutputInterface $output)
	{
		$this->user = $user;
		$this->output = $output;
	}

	/**
	 * {@inheritdoc}
	 */
	public function write($message, $verbosity)
	{
		if ($verbosity <= $this->output->getVerbosity())
		{
			$translated_message = call_user_func_array(array($this->user, 'lang'), $message);

			if ($verbosity === migrator_output_handler_interface::VERBOSITY_NORMAL)
			{
				$translated_message = '<info>' . $translated_message . '</info>';
			}
			else if ($verbosity === migrator_output_handler_interface::VERBOSITY_VERBOSE)
			{
				$translated_message = '<comment>' . $translated_message . '</comment>';
			}

			$this->output->writeln($translated_message);
		}
	}
}