aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/console
diff options
context:
space:
mode:
authorJoshyPHP <s9e.dev@gmail.com>2015-06-29 23:05:52 +0200
committerJoshyPHP <s9e.dev@gmail.com>2015-06-30 10:32:00 +0200
commitfadb192c570db25fe4b36b1b3803fb923e6f9d4e (patch)
treefd54de73c61cd309f6f9bad643009f86cc9158a4 /phpBB/phpbb/console
parent119f90e36301463ffd01005a9390d3346be7774f (diff)
downloadforums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.tar
forums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.tar.gz
forums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.tar.bz2
forums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.tar.xz
forums-fadb192c570db25fe4b36b1b3803fb923e6f9d4e.zip
[ticket/13891] Added command-line options
PHPBB3-13891
Diffstat (limited to 'phpBB/phpbb/console')
-rw-r--r--phpBB/phpbb/console/command/reparser/reparse.php43
1 files changed, 34 insertions, 9 deletions
diff --git a/phpBB/phpbb/console/command/reparser/reparse.php b/phpBB/phpbb/console/command/reparser/reparse.php
index 8cefee837f..5e1993d44c 100644
--- a/phpBB/phpbb/console/command/reparser/reparse.php
+++ b/phpBB/phpbb/console/command/reparser/reparse.php
@@ -15,6 +15,7 @@ namespace phpbb\console\command\reparser;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class reparse extends \phpbb\console\command\command
@@ -49,6 +50,26 @@ class reparse extends \phpbb\console\command\command
->setName('reparser:reparse')
->setDescription($this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE'))
->addArgument('reparser-name', InputArgument::OPTIONAL, $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_ARG_1'))
+ ->addOption(
+ 'range-min',
+ null,
+ InputOption::VALUE_REQUIRED,
+ $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MIN'),
+ 0
+ )
+ ->addOption(
+ 'range-max',
+ null,
+ InputOption::VALUE_REQUIRED,
+ $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_MAX')
+ )
+ ->addOption(
+ 'range-size',
+ null,
+ InputOption::VALUE_REQUIRED,
+ $this->user->lang('CLI_DESCRIPTION_REPARSER_REPARSE_OPT_RANGE_SIZE'),
+ 100
+ );
;
}
@@ -69,13 +90,13 @@ class reparse extends \phpbb\console\command\command
{
$name = 'text_reparser.' . $name;
}
- $this->reparse($output, $name);
+ $this->reparse($input, $output, $name);
}
else
{
foreach ($this->reparsers as $name => $service)
{
- $this->reparse($output, $name);
+ $this->reparse($input, $output, $name);
}
}
@@ -83,24 +104,28 @@ class reparse extends \phpbb\console\command\command
}
/**
- * Reparse all text handled by given reparser
+ * Reparse all text handled by given reparser within given range
*
+ * @param InputInterface $input
* @param OutputInterface $output
* @param string $name Reparser name
* @return null
*/
- protected function reparse(OutputInterface $output, $name)
+ protected function reparse(InputInterface $input, OutputInterface $output, $name)
{
$reparser = $this->reparsers[$name];
- $id = $reparser->get_max_id();
- $n = 100;
- while ($id > 0)
+
+ // Start at range-max if specified or at the highest ID otherwise
+ $id = (is_null($input->getOption('range-max'))) ? $reparser->get_max_id() : $input->getOption('range-max');
+ $min = $input->getOption('range-min');
+ $size = $input->getOption('range-size');
+ while ($id > $min)
{
- $start = max(0, $id + 1 - $n);
+ $start = max($min, $id + 1 - $size);
$end = $id;
$output->writeln('<info>' . $this->user->lang('CLI_REPARSER_REPARSE_REPARSING', $name, $start, $end) . '</info>');
$reparser->reparse_range($start, $end);
- $id -= $n;
+ $id -= $size;
}
}
}