mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-19 01:38:54 +00:00
[ticket/14895] Use SymfonyStyle in all CLI
PHPBB3-14895
This commit is contained in:
parent
d275fefc69
commit
b17fa7dfa5
15 changed files with 100 additions and 83 deletions
4
phpBB/phpbb/console/command/cache/purge.php
vendored
4
phpBB/phpbb/console/command/cache/purge.php
vendored
|
@ -14,6 +14,7 @@ namespace phpbb\console\command\cache;
|
||||||
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class purge extends \phpbb\console\command\command
|
class purge extends \phpbb\console\command\command
|
||||||
{
|
{
|
||||||
|
@ -84,6 +85,7 @@ class purge extends \phpbb\console\command\command
|
||||||
|
|
||||||
$this->log->add('admin', ANONYMOUS, '', 'LOG_PURGE_CACHE', time(), array());
|
$this->log->add('admin', ANONYMOUS, '', 'LOG_PURGE_CACHE', time(), array());
|
||||||
|
|
||||||
$output->writeln($this->user->lang('PURGE_CACHE_SUCCESS'));
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
$io->success($this->user->lang('PURGE_CACHE_SUCCESS'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace phpbb\console\command\config;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class delete extends command
|
class delete extends command
|
||||||
{
|
{
|
||||||
|
@ -47,17 +48,19 @@ class delete extends command
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$key = $input->getArgument('key');
|
$key = $input->getArgument('key');
|
||||||
|
|
||||||
if (isset($this->config[$key]))
|
if (isset($this->config[$key]))
|
||||||
{
|
{
|
||||||
$this->config->delete($key);
|
$this->config->delete($key);
|
||||||
|
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_CONFIG_DELETE_SUCCESS', $key) . '</info>');
|
$io->success($this->user->lang('CLI_CONFIG_DELETE_SUCCESS', $key));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $this->user->lang('CLI_CONFIG_NOT_EXISTS', $key) . '</error>');
|
$io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class get extends command
|
class get extends command
|
||||||
{
|
{
|
||||||
|
@ -54,6 +55,8 @@ class get extends command
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$key = $input->getArgument('key');
|
$key = $input->getArgument('key');
|
||||||
|
|
||||||
if (isset($this->config[$key]) && $input->getOption('no-newline'))
|
if (isset($this->config[$key]) && $input->getOption('no-newline'))
|
||||||
|
@ -66,7 +69,7 @@ class get extends command
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $this->user->lang('CLI_CONFIG_NOT_EXISTS', $key) . '</error>');
|
$io->error($this->user->lang('CLI_CONFIG_NOT_EXISTS', $key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class increment extends command
|
class increment extends command
|
||||||
{
|
{
|
||||||
|
@ -59,12 +60,14 @@ class increment extends command
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$key = $input->getArgument('key');
|
$key = $input->getArgument('key');
|
||||||
$increment = $input->getArgument('increment');
|
$increment = $input->getArgument('increment');
|
||||||
$use_cache = !$input->getOption('dynamic');
|
$use_cache = !$input->getOption('dynamic');
|
||||||
|
|
||||||
$this->config->increment($key, $increment, $use_cache);
|
$this->config->increment($key, $increment, $use_cache);
|
||||||
|
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_CONFIG_INCREMENT_SUCCESS', $key) . '</info>');
|
$io->success($this->user->lang('CLI_CONFIG_INCREMENT_SUCCESS', $key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class set extends command
|
class set extends command
|
||||||
{
|
{
|
||||||
|
@ -59,12 +60,14 @@ class set extends command
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$key = $input->getArgument('key');
|
$key = $input->getArgument('key');
|
||||||
$value = $input->getArgument('value');
|
$value = $input->getArgument('value');
|
||||||
$use_cache = !$input->getOption('dynamic');
|
$use_cache = !$input->getOption('dynamic');
|
||||||
|
|
||||||
$this->config->set($key, $value, $use_cache);
|
$this->config->set($key, $value, $use_cache);
|
||||||
|
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_CONFIG_SET_SUCCESS', $key) . '</info>');
|
$io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class set_atomic extends command
|
class set_atomic extends command
|
||||||
{
|
{
|
||||||
|
@ -65,6 +66,8 @@ class set_atomic extends command
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$key = $input->getArgument('key');
|
$key = $input->getArgument('key');
|
||||||
$old_value = $input->getArgument('old');
|
$old_value = $input->getArgument('old');
|
||||||
$new_value = $input->getArgument('new');
|
$new_value = $input->getArgument('new');
|
||||||
|
@ -72,12 +75,12 @@ class set_atomic extends command
|
||||||
|
|
||||||
if ($this->config->set_atomic($key, $old_value, $new_value, $use_cache))
|
if ($this->config->set_atomic($key, $old_value, $new_value, $use_cache))
|
||||||
{
|
{
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_CONFIG_SET_SUCCESS', $key) . '</info>');
|
$io->success($this->user->lang('CLI_CONFIG_SET_SUCCESS', $key));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $this->user->lang('CLI_CONFIG_SET_FAILURE', $key) . '</error>');
|
$io->error($this->user->lang('CLI_CONFIG_SET_FAILURE', $key));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace phpbb\console\command\cron;
|
||||||
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class cron_list extends \phpbb\console\command\command
|
class cron_list extends \phpbb\console\command\command
|
||||||
{
|
{
|
||||||
|
@ -55,57 +56,39 @@ class cron_list extends \phpbb\console\command\command
|
||||||
*/
|
*/
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$tasks = $this->cron_manager->get_tasks();
|
$tasks = $this->cron_manager->get_tasks();
|
||||||
|
|
||||||
if (empty($tasks))
|
if (empty($tasks))
|
||||||
{
|
{
|
||||||
$output->writeln($this->user->lang('CRON_NO_TASKS'));
|
$io->error($this->user->lang('CRON_NO_TASKS'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ready_tasks = array();
|
$ready_tasks = $not_ready_tasks = array();
|
||||||
$not_ready_tasks = array();
|
|
||||||
foreach ($tasks as $task)
|
foreach ($tasks as $task)
|
||||||
{
|
{
|
||||||
if ($task->is_ready())
|
if ($task->is_ready())
|
||||||
{
|
{
|
||||||
$ready_tasks[] = $task;
|
$ready_tasks[] = $task->get_name();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$not_ready_tasks[] = $task;
|
$not_ready_tasks[] = $task->get_name();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($ready_tasks))
|
if (!empty($ready_tasks))
|
||||||
{
|
{
|
||||||
$output->writeln('<info>' . $this->user->lang('TASKS_READY') . '</info>');
|
$io->section($this->user->lang('TASKS_READY'));
|
||||||
$this->print_tasks_names($ready_tasks, $output);
|
$io->listing($ready_tasks);
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($ready_tasks) && !empty($not_ready_tasks))
|
|
||||||
{
|
|
||||||
$output->writeln('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($not_ready_tasks))
|
if (!empty($not_ready_tasks))
|
||||||
{
|
{
|
||||||
$output->writeln('<info>' . $this->user->lang('TASKS_NOT_READY') . '</info>');
|
$io->section($this->user->lang('TASKS_NOT_READY'));
|
||||||
$this->print_tasks_names($not_ready_tasks, $output);
|
$io->listing($not_ready_tasks);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Print a list of cron jobs
|
|
||||||
*
|
|
||||||
* @param array $tasks A list of task to display
|
|
||||||
* @param OutputInterface $output An OutputInterface instance
|
|
||||||
*/
|
|
||||||
protected function print_tasks_names(array $tasks, OutputInterface $output)
|
|
||||||
{
|
|
||||||
foreach ($tasks as $task)
|
|
||||||
{
|
|
||||||
$output->writeln($task->get_name());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace phpbb\console\command\db;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class list_command extends \phpbb\console\command\db\migration_command
|
class list_command extends \phpbb\console\command\db\migration_command
|
||||||
{
|
{
|
||||||
|
@ -34,6 +35,8 @@ class list_command extends \phpbb\console\command\db\migration_command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$show_installed = !$input->getOption('available');
|
$show_installed = !$input->getOption('available');
|
||||||
$installed = $available = array();
|
$installed = $available = array();
|
||||||
|
|
||||||
|
@ -51,23 +54,28 @@ class list_command extends \phpbb\console\command\db\migration_command
|
||||||
|
|
||||||
if ($show_installed)
|
if ($show_installed)
|
||||||
{
|
{
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_MIGRATIONS_INSTALLED') . $this->user->lang('COLON') . '</info>');
|
$io->section($this->user->lang('CLI_MIGRATIONS_INSTALLED'));
|
||||||
$output->writeln($installed);
|
|
||||||
|
|
||||||
if (empty($installed))
|
if (!empty($installed))
|
||||||
{
|
{
|
||||||
$output->writeln($this->user->lang('CLI_MIGRATIONS_EMPTY'));
|
$io->listing($installed);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$io->text($this->user->lang('CLI_MIGRATIONS_EMPTY'));
|
||||||
|
$io->newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_MIGRATIONS_AVAILABLE') . $this->user->lang('COLON') . '</info>');
|
$io->section($this->user->lang('CLI_MIGRATIONS_AVAILABLE'));
|
||||||
$output->writeln($available);
|
if (!empty($available))
|
||||||
|
|
||||||
if (empty($available))
|
|
||||||
{
|
{
|
||||||
$output->writeln($this->user->lang('CLI_MIGRATIONS_EMPTY'));
|
$io->listing($available);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$io->text($this->user->lang('CLI_MIGRATIONS_EMPTY'));
|
||||||
|
$io->newLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace phpbb\console\command\db;
|
||||||
use phpbb\db\output_handler\log_wrapper_migrator_output_handler;
|
use phpbb\db\output_handler\log_wrapper_migrator_output_handler;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class migrate extends \phpbb\console\command\db\migration_command
|
class migrate extends \phpbb\console\command\db\migration_command
|
||||||
{
|
{
|
||||||
|
@ -50,6 +51,8 @@ class migrate extends \phpbb\console\command\db\migration_command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
|
$this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
|
||||||
|
|
||||||
$this->migrator->create_migrations_table();
|
$this->migrator->create_migrations_table();
|
||||||
|
@ -66,7 +69,7 @@ class migrate extends \phpbb\console\command\db\migration_command
|
||||||
}
|
}
|
||||||
catch (\phpbb\db\migration\exception $e)
|
catch (\phpbb\db\migration\exception $e)
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $e->getLocalisedMessage($this->user) . '</error>');
|
$io->error($e->getLocalisedMessage($this->user));
|
||||||
$this->finalise_update();
|
$this->finalise_update();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -78,6 +81,6 @@ class migrate extends \phpbb\console\command\db\migration_command
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->finalise_update();
|
$this->finalise_update();
|
||||||
$output->writeln($this->user->lang['DATABASE_UPDATE_COMPLETE']);
|
$io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ use phpbb\db\output_handler\log_wrapper_migrator_output_handler;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class revert extends \phpbb\console\command\db\migration_command
|
class revert extends \phpbb\console\command\db\migration_command
|
||||||
{
|
{
|
||||||
|
@ -52,6 +53,8 @@ class revert extends \phpbb\console\command\db\migration_command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$name = str_replace('/', '\\', $input->getArgument('name'));
|
$name = str_replace('/', '\\', $input->getArgument('name'));
|
||||||
|
|
||||||
$this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
|
$this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
|
||||||
|
@ -60,12 +63,12 @@ class revert extends \phpbb\console\command\db\migration_command
|
||||||
|
|
||||||
if (!in_array($name, $this->load_migrations()))
|
if (!in_array($name, $this->load_migrations()))
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $this->user->lang('MIGRATION_NOT_VALID', $name) . '</error>');
|
$io->error($this->language->lang('MIGRATION_NOT_VALID', $name));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else if ($this->migrator->migration_state($name) === false)
|
else if ($this->migrator->migration_state($name) === false)
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $this->user->lang('MIGRATION_NOT_INSTALLED', $name) . '</error>');
|
$io->error($this->language->lang('MIGRATION_NOT_INSTALLED', $name));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,11 +81,12 @@ class revert extends \phpbb\console\command\db\migration_command
|
||||||
}
|
}
|
||||||
catch (\phpbb\db\migration\exception $e)
|
catch (\phpbb\db\migration\exception $e)
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $e->getLocalisedMessage($this->user) . '</error>');
|
$io->error($e->getLocalisedMessage($this->user));
|
||||||
$this->finalise_update();
|
$this->finalise_update();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->finalise_update();
|
$this->finalise_update();
|
||||||
|
$io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace phpbb\console\command\extension;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class disable extends command
|
class disable extends command
|
||||||
{
|
{
|
||||||
|
@ -33,19 +34,21 @@ class disable extends command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$name = $input->getArgument('extension-name');
|
$name = $input->getArgument('extension-name');
|
||||||
$this->manager->disable($name);
|
$this->manager->disable($name);
|
||||||
$this->manager->load_extensions();
|
$this->manager->load_extensions();
|
||||||
|
|
||||||
if ($this->manager->is_enabled($name))
|
if ($this->manager->is_enabled($name))
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $this->user->lang('CLI_EXTENSION_DISABLE_FAILURE', $name) . '</error>');
|
$io->error($this->user->lang('CLI_EXTENSION_DISABLE_FAILURE', $name));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_DISABLE', time(), array($name));
|
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_DISABLE', time(), array($name));
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_EXTENSION_DISABLE_SUCCESS', $name) . '</info>');
|
$io->success($this->user->lang('CLI_EXTENSION_DISABLE_SUCCESS', $name));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace phpbb\console\command\extension;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class enable extends command
|
class enable extends command
|
||||||
{
|
{
|
||||||
|
@ -33,6 +34,8 @@ class enable extends command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$name = $input->getArgument('extension-name');
|
$name = $input->getArgument('extension-name');
|
||||||
$this->manager->enable($name);
|
$this->manager->enable($name);
|
||||||
$this->manager->load_extensions();
|
$this->manager->load_extensions();
|
||||||
|
@ -40,12 +43,12 @@ class enable extends command
|
||||||
if ($this->manager->is_enabled($name))
|
if ($this->manager->is_enabled($name))
|
||||||
{
|
{
|
||||||
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name));
|
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_ENABLE', time(), array($name));
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name) . '</info>');
|
$io->success($this->user->lang('CLI_EXTENSION_ENABLE_SUCCESS', $name));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name) . '</error>');
|
$io->error($this->user->lang('CLI_EXTENSION_ENABLE_FAILURE', $name));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ namespace phpbb\console\command\extension;
|
||||||
use Symfony\Component\Console\Input\InputArgument;
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class purge extends command
|
class purge extends command
|
||||||
{
|
{
|
||||||
|
@ -33,19 +34,21 @@ class purge extends command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$name = $input->getArgument('extension-name');
|
$name = $input->getArgument('extension-name');
|
||||||
$this->manager->purge($name);
|
$this->manager->purge($name);
|
||||||
$this->manager->load_extensions();
|
$this->manager->load_extensions();
|
||||||
|
|
||||||
if ($this->manager->is_enabled($name))
|
if ($this->manager->is_enabled($name))
|
||||||
{
|
{
|
||||||
$output->writeln('<error>' . $this->user->lang('CLI_EXTENSION_PURGE_FAILURE', $name) . '</error>');
|
$io->error($this->user->lang('CLI_EXTENSION_PURGE_FAILURE', $name));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_PURGE', time(), array($name));
|
$this->log->add('admin', ANONYMOUS, '', 'LOG_EXT_PURGE', time(), array($name));
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_EXTENSION_PURGE_SUCCESS', $name) . '</info>');
|
$io->success($this->user->lang('CLI_EXTENSION_PURGE_SUCCESS', $name));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace phpbb\console\command\extension;
|
||||||
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class show extends command
|
class show extends command
|
||||||
{
|
{
|
||||||
|
@ -27,36 +28,27 @@ class show extends command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$this->manager->load_extensions();
|
$this->manager->load_extensions();
|
||||||
$all = array_keys($this->manager->all_available());
|
$all = array_keys($this->manager->all_available());
|
||||||
|
|
||||||
if (empty($all))
|
if (empty($all))
|
||||||
{
|
{
|
||||||
$output->writeln('<comment>' . $this->user->lang('CLI_EXTENSION_NOT_FOUND') . '</comment>');
|
$io->note($this->user->lang('CLI_EXTENSION_NOT_FOUND'));
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
$enabled = array_keys($this->manager->all_enabled());
|
$enabled = array_keys($this->manager->all_enabled());
|
||||||
$this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_ENABLED') . $this->user->lang('COLON'), $enabled);
|
$io->section($this->user->lang('CLI_EXTENSIONS_ENABLED'));
|
||||||
|
$io->listing($enabled);
|
||||||
$output->writeln('');
|
|
||||||
|
|
||||||
$disabled = array_keys($this->manager->all_disabled());
|
$disabled = array_keys($this->manager->all_disabled());
|
||||||
$this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_DISABLED') . $this->user->lang('COLON'), $disabled);
|
$io->section($this->user->lang('CLI_EXTENSIONS_DISABLED'));
|
||||||
|
$io->listing($disabled);
|
||||||
$output->writeln('');
|
|
||||||
|
|
||||||
$purged = array_diff($all, $enabled, $disabled);
|
$purged = array_diff($all, $enabled, $disabled);
|
||||||
$this->print_extension_list($output, $this->user->lang('CLI_EXTENSIONS_AVAILABLE') . $this->user->lang('COLON'), $purged);
|
$io->section($this->user->lang('CLI_EXTENSIONS_AVAILABLE'));
|
||||||
}
|
$io->listing($purged);
|
||||||
|
|
||||||
protected function print_extension_list(OutputInterface $output, $type, array $extensions)
|
|
||||||
{
|
|
||||||
$output->writeln("<info>$type</info>");
|
|
||||||
|
|
||||||
foreach ($extensions as $extension)
|
|
||||||
{
|
|
||||||
$output->writeln(" - $extension");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace phpbb\console\command\fixup;
|
||||||
|
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
class recalculate_email_hash extends \phpbb\console\command\command
|
class recalculate_email_hash extends \phpbb\console\command\command
|
||||||
{
|
{
|
||||||
|
@ -37,6 +38,8 @@ class recalculate_email_hash extends \phpbb\console\command\command
|
||||||
|
|
||||||
protected function execute(InputInterface $input, OutputInterface $output)
|
protected function execute(InputInterface $input, OutputInterface $output)
|
||||||
{
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
$sql = 'SELECT user_id, user_email, user_email_hash
|
$sql = 'SELECT user_id, user_email, user_email_hash
|
||||||
FROM ' . USERS_TABLE . '
|
FROM ' . USERS_TABLE . '
|
||||||
WHERE user_type <> ' . USER_IGNORE . "
|
WHERE user_type <> ' . USER_IGNORE . "
|
||||||
|
@ -59,17 +62,15 @@ class recalculate_email_hash extends \phpbb\console\command\command
|
||||||
|
|
||||||
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG)
|
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG)
|
||||||
{
|
{
|
||||||
$output->writeln(sprintf(
|
$io->table(
|
||||||
'user_id %d, email %s => %s',
|
array('user_id', 'user_email', 'user_email_hash'),
|
||||||
$row['user_id'],
|
array(array($row['user_id'], $row['user_email'], $user_email_hash))
|
||||||
$row['user_email'],
|
);
|
||||||
$user_email_hash
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->db->sql_freeresult($result);
|
$this->db->sql_freeresult($result);
|
||||||
|
|
||||||
$output->writeln('<info>' . $this->user->lang('CLI_FIXUP_RECALCULATE_EMAIL_HASH_SUCCESS') . '</info>');
|
$io->success($this->user->lang('CLI_FIXUP_RECALCULATE_EMAIL_HASH_SUCCESS'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue