本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar::setFormatDefinition方法的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar::setFormatDefinition方法的具体用法?PHP ProgressBar::setFormatDefinition怎么用?PHP ProgressBar::setFormatDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\ProgressBar
的用法示例。
在下文中一共展示了ProgressBar::setFormatDefinition方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* {@inheritDoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->em = $this->getEntityManager();
if (class_exists('Symfony\\Component\\Console\\Helper\\ProgressBar')) {
ProgressBar::setFormatDefinition('normal', " %current%/%max% [%bar%] %percent:3s%%\n%message%");
ProgressBar::setFormatDefinition('verbose', " %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%\n%message%");
ProgressBar::setFormatDefinition('very_verbose', " %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%\n%message%");
ProgressBar::setFormatDefinition('debug', " %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%\n%message%");
}
}
示例2: setupFormat
/**
* @return void
*/
protected function setupFormat()
{
ProgressBar::setFormatDefinition('normal_nomax', ' <fg=yellow>*</fg=yellow> <fg=green>%barTitle%</fg=green> <fg=yellow>(%max%)</fg=yellow>');
ProgressBar::setFormatDefinition('verbose_nomax', ' <fg=yellow>*</fg=yellow> <fg=green>%barTitle%</fg=green> <fg=yellow>(%max%)</fg=yellow>');
ProgressBar::setFormatDefinition('very_verbose_nomax', ' <fg=yellow>*</fg=yellow> <fg=green>%barTitle%</fg=green> <fg=yellow>(%max%)</fg=yellow>');
ProgressBar::setFormatDefinition('debug_nomax', ' <fg=yellow>*</fg=yellow> <fg=green>%barTitle%</fg=green> <fg=yellow>(%max%)</fg=yellow>');
ProgressBar::setFormatDefinition('normal', ' <fg=yellow>*</fg=yellow> <fg=green>%barTitle%</fg=green> <fg=yellow>(%max%)</fg=yellow>');
ProgressBar::setFormatDefinition('verbose', ' <fg=yellow>*</fg=yellow> <fg=green>%barTitle%</fg=green> <fg=yellow>%percent%% (%current%/%max%) %elapsed:6s%</fg=yellow>');
ProgressBar::setFormatDefinition('very_verbose', " <fg=yellow>*</fg=yellow> <fg=green>%barTitle:-25s%</fg=green> [%bar%] <fg=yellow>%percent%% (%current%/%max%) %elapsed:6s% %memory:6s%</fg=yellow>\r");
ProgressBar::setFormatDefinition('debug', " <fg=yellow>*</fg=yellow> <fg=green>%barTitle:-25s%</fg=green> %bar% <fg=yellow>%percent:20s%% [%current%/%max%] Memory: %memory%, Elapsed: %elapsed%, Remaining: %remaining%</fg=yellow>\r");
}
示例3: initialize
/**
* {@inheritDoc}
*/
protected function initialize(InputInterface $input, OutputInterface $output)
{
$this->dispatcher = $this->getContainer()->get('event_dispatcher');
$this->indexManager = $this->getContainer()->get('fos_elastica.index_manager');
$this->providerRegistry = $this->getContainer()->get('fos_elastica.provider_registry');
$this->resetter = $this->getContainer()->get('fos_elastica.resetter');
$this->progressClosureBuilder = new ProgressClosureBuilder();
if (!$input->getOption('no-overwrite-format') && class_exists('Symfony\\Component\\Console\\Helper\\ProgressBar')) {
ProgressBar::setFormatDefinition('normal', " %current%/%max% [%bar%] %percent:3s%%\n%message%");
ProgressBar::setFormatDefinition('verbose', " %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%\n%message%");
ProgressBar::setFormatDefinition('very_verbose', " %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%\n%message%");
ProgressBar::setFormatDefinition('debug', " %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%\n%message%");
}
}
示例4: __construct
/**
* Initializes a new instance of the Reporter class.
*
* @param $output
* @param $total
*
* @return Reporter
*/
public function __construct(OutputInterface $output, $total)
{
$this->issues = new IssueCollection();
$this->output = $output;
if ($total > 1) {
$this->output->writeln('');
ProgressBar::setFormatDefinition('minimal', ' <fg=cyan>Reviewing file %current% of %max%.</>');
$this->progress = new ProgressBar($output, $total);
$this->progress->setFormat('minimal');
$this->progress->start();
}
$this->total = $total;
$this->current = 1;
}
示例5: __construct
/**
* TerminusStyle constructor.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*/
public function __construct(InputInterface $input, OutputInterface $output)
{
ProgressBar::setFormatDefinition('normal', self::NORMAL_PROGRESS_FORMAT);
parent::__construct($input, $output);
}
示例6: copyTable
protected function copyTable($table, $keyColumn = false)
{
$columns = join(array_map(function ($column) {
return $this->sc->quoteIdentifier($column->getName());
}, $table->getColumns()), ',');
$sqlParameters = array();
$maxKey = null;
// set selection range
if ($keyColumn) {
$sqlMax = 'SELECT MAX(' . $this->tc->quoteIdentifier($keyColumn) . ') ' . 'FROM ' . $this->tc->quoteIdentifier($table->getName());
$maxKey = $this->tc->fetchColumn($sqlMax);
if (isset($maxKey)) {
$sqlParameters[] = $maxKey;
}
} else {
// clear target table
$this->truncateTable($this->tc, $table);
}
echo $table->getName() . ": copying ";
// count selection range
$sqlCount = 'SELECT COUNT(1) FROM (' . $this->sc->quoteIdentifier($table->getName()) . ')';
if ($keyColumn && isset($maxKey)) {
$sqlCount .= ' WHERE ' . $this->sc->quoteIdentifier($keyColumn) . ' > ?';
}
$totalRows = $this->sc->fetchColumn($sqlCount, $sqlParameters);
echo $totalRows . " rows (" . ($keyColumn ? 'partial copy' : 'overwrite') . ")\n";
$progress = new ProgressBar($this->output, $totalRows);
$progress->setFormatDefinition('debug', ' [%bar%] %percent:3s%% %elapsed:8s%/%estimated:-8s% %current% rows');
$progress->setFormat('debug');
$freq = (int) $totalRows / 20;
$progress->setRedrawFrequency($freq > 10 ? $freq : 10);
$progress->start();
// transfer sql
$sqlValuePlaceholder = '(' . join(array_fill(0, sizeof($table->getColumns()), '?'), ',') . ')';
$loopOffsetIndex = 0;
do {
// get source data
$sql = 'SELECT ' . $columns . ' FROM ' . $this->sc->quoteIdentifier($table->getName());
// limit selection for PRIMARY KEY mode
if ($keyColumn) {
if (isset($maxKey)) {
$sql .= ' WHERE ' . $this->sc->quoteIdentifier($keyColumn) . ' > ?';
$sqlParameters = array($maxKey);
}
$sql .= ' ORDER BY ' . $this->sc->quoteIdentifier($keyColumn) . ' LIMIT ' . $this->batch;
} else {
$sql .= ' LIMIT ' . $this->batch . ' OFFSET ' . $this->batch * $loopOffsetIndex++;
}
if (sizeof($rows = $this->sc->fetchAll($sql, $sqlParameters)) == 0) {
// avoid div by zero in progress->advance
break;
}
if ($this->tc->getDatabasePlatform()->getName() !== 'sqlite') {
$sqlInsert = 'INSERT INTO ' . $this->tc->quoteIdentifier($table->getName()) . ' (' . $columns . ') ' . 'VALUES ' . join(array_fill(0, count($rows), $sqlValuePlaceholder), ',');
$data = array();
foreach ($rows as $row) {
// remember max key
if ($keyColumn) {
$maxKey = $row[$keyColumn];
}
$data = array_merge($data, array_values($row));
}
$this->tc->executeUpdate($sqlInsert, $data);
$progress->advance(count($rows));
} else {
// sqlite
$stmt = $this->tc->prepare('INSERT INTO ' . $this->tc->quoteIdentifier($table->getName()) . ' (' . $columns . ') ' . 'VALUES (' . join(array_fill(0, count($table->getColumns()), '?'), ',') . ')');
$this->tc->beginTransaction();
foreach ($rows as $row) {
// remember max key
if ($keyColumn) {
$maxKey = $row[$keyColumn];
}
$stmt->execute(array_values($row));
$progress->advance(1);
}
$this->tc->commit();
}
} while ($keyColumn && sizeof($rows));
$progress->finish();
echo "\n\n";
// CRLF after progressbar @ 100%
}