本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar::finish方法的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar::finish方法的具体用法?PHP ProgressBar::finish怎么用?PHP ProgressBar::finish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\ProgressBar
的用法示例。
在下文中一共展示了ProgressBar::finish方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: start
/**
* {@inheritdoc}
*/
public function start()
{
$dispatcher = $this->getDispatcher();
$sourceEvent = new SourcePipelineEvent();
$sourceEvent->setContext($this->getContext());
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_SOURCE), $sourceEvent);
$this->setContext($sourceEvent->getContext());
$sources = $sourceEvent->getSources();
$outputs = [];
$startEvent = new StartPipelineEvent();
$startEvent->setContext($this->getContext());
$startEvent->setItemCount($this->countSourceItems($sources));
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_START), $startEvent);
$this->setContext($startEvent->getContext());
$this->progressBar && $this->progressBar->start($this->countSourceItems($sources));
foreach ($sources as $source) {
foreach ($source as $item) {
$itemEvent = new ItemPipelineEvent($item);
$itemEvent->setContext($this->getContext());
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_MODIFY), $itemEvent);
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_CONSUME), $itemEvent);
$output = $itemEvent->getOutput();
if ($output !== null) {
$outputs[] = $output;
}
$this->setContext($itemEvent->getContext());
$this->progressBar && $this->progressBar->advance();
}
}
$finishEvent = new FinishPipelineEvent();
$finishEvent->setContext($this->getContext());
$dispatcher->dispatch($this->getEventName(self::EVENT_SUFFIX_FINISH), $finishEvent);
$this->progressBar && $this->progressBar->finish();
return ['outputs' => $outputs];
}
示例2: finish
public function finish()
{
if ($this->progressBar !== null) {
$this->progressBar->finish();
$this->output->writeln('');
}
}
示例3: execute
/**
* Execute the generator command.
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->themes = $this->loadThemes();
$this->patterns = $this->loadPatterns();
$this->setupProgressBar($output);
$twig = new Twig_Environment(new Twig_Loader_Filesystem(BASE_PATH . '/resources/files'));
foreach ($this->themes as $theme) {
$theme->year = date('Y');
$theme->uuid = Uuid::uuid4()->toString();
foreach ($this->patterns as $pattern) {
$this->progress->setMessage("Generating '{$theme->theme->name}' theme for '{$pattern->name}'.");
foreach ($pattern->files as $source => $destination) {
$result = $twig->render($source, (array) $theme);
$destination = str_replace('{{theme}}', $theme->theme->slug, $destination);
if (count($pattern->files) > 1) {
$output = BASE_PATH . "/output/{$pattern->slug}/{$theme->theme->slug}/{$destination}";
} else {
$output = BASE_PATH . "/output/{$pattern->slug}/{$destination}";
}
@mkdir(dirname($output), 0777, true);
file_put_contents($output, $result);
}
$this->progress->advance();
}
}
$this->progress->setMessage("Enjoy the themes!");
$this->progress->finish();
}
示例4: download
/**
* Download the file to the specified path
* @return string path to the downloaded file
*/
public function download()
{
if (!ini_get('allow_url_fopen')) {
throw new Exception('allow_url_fopen is disabled.');
}
// open the temp file for writing
$fileHandle = fopen($this->path, 'wb');
if ($fileHandle === false) {
throw new Exception('Could not open temp file.');
}
// download context so we can track download progress
$downloadContext = stream_context_create(array(), array('notification' => array($this, 'showDownloadProgress')));
// open the download url for reading
$downloadHandle = @fopen($this->url, 'rb', false, $downloadContext);
if ($downloadHandle === false) {
throw new Exception('Could not download installation file.');
}
while (!feof($downloadHandle)) {
if (fwrite($fileHandle, fread($downloadHandle, 1024)) === false) {
throw new Exception('Could not write installation file to disk.');
}
}
fclose($downloadHandle);
fclose($fileHandle);
if ($this->progressBar) {
$this->progressBar->finish();
$this->output->writeln('');
}
return $this->path;
}
示例5: test
protected function test($count, $classes, OutputInterface $output)
{
$this->table = new Table($output);
$this->table->setHeaders(array('Implementation', 'Memory', 'Duration'));
$output->writeln(sprintf('<info>%d elements</info>', $count));
$this->process = new ProgressBar($output, count($classes));
$this->process->start();
foreach ($classes as $class) {
$shortClass = $class;
// if (in_array($class, $blacklist)) {
// $this->table->addRow([$class, '--', '--']);
// continue;
// };
$path = __DIR__ . '/../../bin/test.php';
$result = `php {$path} {$class} {$count}`;
$data = json_decode($result, true);
if (!$data) {
echo $result;
}
$this->table->addRow([$shortClass, sprintf('%11sb', number_format($data['memory'])), sprintf('%6.4fs', $data['time'])]);
$this->process->advance();
}
$this->process->finish();
$output->writeln('');
$this->table->render($output);
}
示例6: onPostFetch
/**
* @param TransportEvent $event
*/
public function onPostFetch(TransportEvent $event)
{
if ($this->progressActive) {
$this->progress->finish();
$this->progressActive = false;
}
$this->progress->setMessage(sprintf('Saved to <info>%s</info>', $event->getTransport()->getDestination()));
}
示例7: end
public function end()
{
if (!$this->verbose) {
return;
}
$this->progressBar->clear();
$this->progressBar->finish();
}
示例8: finishProgress
/**
* @param RunnerEvent $runnerEvent
*/
public function finishProgress(RunnerEvent $runnerEvent)
{
if ($this->progressBar->getProgress() != $this->progressBar->getMaxSteps()) {
$this->progressBar->setFormat('<fg=red>%message%</fg=red>');
$this->progressBar->setMessage('Aborted ...');
}
$this->progressBar->finish();
$this->output->writeln('');
}
示例9: fire
/**
* {@inheritdoc}
*/
protected function fire()
{
$tasks = $this->craft->tasks->getAllTasks();
if (!$tasks) {
$this->info('No pending tasks.');
return;
}
foreach ($tasks as $task) {
if ($task->status === TaskStatus::Running) {
if ($this->option('reset-running')) {
$this->resetTask($task);
} else {
continue;
}
}
if ($task->status === TaskStatus::Error) {
if ($this->option('reset-failed')) {
$this->resetTask($task);
} else {
continue;
}
}
try {
$taskRecord = TaskRecord::model()->findById($task->id);
$taskType = $task->getTaskType();
if (!$taskType) {
throw new Exception('Could not find task type for task ID ' . $task->id);
}
$task->totalSteps = $taskType->getTotalSteps();
$task->status = TaskStatus::Running;
$progressBar = new ProgressBar($this->output, $task->totalSteps);
$this->info($task->description);
for ($step = 0; $step < $task->totalSteps; $step++) {
$task->currentStep = $step + 1;
$this->craft->tasks->saveTask($task);
$result = $taskType->runStep($step);
if ($result !== true) {
$error = is_string($result) ? $result : 'Unknown error';
$progressBar->finish();
$this->line('');
throw new Exception($error);
}
$progressBar->setProgress($task->currentStep);
}
$taskRecord->deleteNode();
$progressBar->finish();
$this->line('');
} catch (Exception $e) {
$this->failTask($task);
$this->error($e->getMessage());
}
}
$this->info('All tasks finished.');
}
示例10: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return null|int null or 0 if everything went fine, or an error code
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$config = Config::getInstance();
$noProgress = $input->getOption('no-progress');
$query = $input->getArgument('query');
$provider = $config->getQuery($query);
if (empty($provider)) {
$output->writeln("<error>cannot found query \"{$query}\"</error>");
$output->writeln("<info>you can execute \"</info>ipv4 edit<info>\" to configure the query</info>");
return 1;
}
$type = $input->getOption('type');
$filename = $config->getFilename($input->getArgument('filename'));
$export = ExportQuery::create($type, $filename);
if (empty($export)) {
$output->writeln("<error>cannot found export query \"{$type}\"</error>");
return 2;
}
$export->setProviders([$provider]);
$encoding = $input->getOption('encoding');
if (!empty($encoding)) {
$export->setEncoding($encoding);
}
$ecdz = $input->getOption('ecdz');
if ($ecdz && method_exists($export, 'setEcdz')) {
$export->setEcdz($ecdz);
}
$remove_ip_in_recode = $input->getOption('remove-ip-in-recode');
if ($remove_ip_in_recode && method_exists($export, 'setRemoveIpInRecode')) {
$export->setRemoveIpInRecode($remove_ip_in_recode);
}
$output->writeln("<info>export \"{$query}\" to \"{$type}\" filename \"{$filename}\":</info>");
if (!$noProgress) {
$export->init(function ($code, $n) use($output) {
switch ($code) {
case 0:
$this->progress = new ProgressBar($output, $n);
$this->progress->start();
break;
case 1:
$this->progress->setProgress($n);
break;
case 2:
$this->progress->finish();
break;
}
});
} else {
$export->init();
}
$output->writeln('<info> completed!</info>');
return 0;
}
示例11: invoke
public function invoke(ElasticPopulator $populator)
{
$begin = function ($total) {
$this->bar = new ProgressBar($this->out, $total);
$this->bar->start();
};
$tick = function () {
$this->bar->advance();
};
$rows = $populator->populate($begin, $tick);
$this->bar->finish();
$this->out->write("\n");
$this->out->writeln("<info>Reindexed {$rows} rows</info>");
}
示例12: output
/**
* @param $args
*/
public function output($args)
{
switch ($args['type']) {
case 'message':
$this->output->writeln($args['message']);
break;
case 'progress':
if ($args['complete']) {
$this->progress->finish();
} else {
$this->progress->advance();
}
break;
}
}
示例13: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
if (!Loader::includeModule('search')) {
throw new BitrixException('Search module is not installed');
}
$searchResult = array();
$bar = new ProgressBar($output, 0);
do {
$bar->display();
$searchResult = \CSearch::ReIndexAll($input->getOption('full'), static::UPDATE_TIME, $searchResult);
$bar->advance();
$bar->clear();
if (is_array($searchResult) && $searchResult['MODULE'] == 'main') {
list(, $path) = explode("|", $searchResult["ID"], 2);
$output->writeln("\r " . $path, OutputInterface::VERBOSITY_VERBOSE);
}
} while (is_array($searchResult));
$bar->finish();
$bar->clear();
$output->write("\r");
if (ModuleManager::isModuleInstalled('socialnetwork')) {
$output->writeln('<info>The Social Network module needs to be reindexed using the Social Network component in the public section of site.</info>');
}
$output->writeln(sprintf('<info>Reindexed</info> %d element%s.', $searchResult, $searchResult > 1 ? 's' : ''));
return 0;
}
示例14: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->dm = $this->getContainer()->get('doctrine_mongodb.odm.default_document_manager');
$allContrats = $this->dm->getRepository('AppBundle:Contrat')->findAll();
$cptTotal = 0;
$i = 0;
$progress = new ProgressBar($output, 100);
$progress->start();
$nb = count($allContrats);
foreach ($allContrats as $contrat) {
if (count($contrat->getMouvements()) > 0) {
foreach ($contrat->getMouvements() as $contratMvt) {
$contratMvt->setTauxTaxe($contrat->getTva());
}
$cptTotal++;
if ($cptTotal % ($nb / 100) == 0) {
$progress->advance();
}
if ($i >= 1000) {
$this->dm->flush();
$i = 0;
}
$i++;
}
}
$this->dm->flush();
$progress->finish();
}
示例15: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($input->getOption('desde')) {
$desde = (int) $input->getOption('desde');
} else {
$desde = 0;
}
if ($input->getOption('hasta')) {
$hasta = (int) $input->getOption('hasta');
} else {
$hasta = 0;
}
$output->writeln('Geocodificando partidas...');
$cantidadTotal = $hasta - $desde;
$progress = null;
$em = $this->getContainer()->get('doctrine')->getManager();
$Helper = new \Yacare\CatastroBundle\Helper\PartidaHelper($this->getContainer(), $em);
$Partidas = $em->getRepository('Yacare\\CatastroBundle\\Entity\\Partida')->findBy(array('Ubicacion' => null), array('id' => 'ASC'), $desde ?: null, $cantidadTotal ?: null);
$progress = new ProgressBar($output, count($Partidas));
$progress->start();
foreach ($Partidas as $Partida) {
$Helper->ObtenerGeoCoding($Partida);
$progress->advance();
$em->flush();
// Dormir entre unos segundos entre consulta y consulta
sleep(rand(10, 20));
}
$em->clear();
$progress->finish();
$output->writeln('');
$output->writeln('Geocodificación terminada, se procesaron ' . count($Partidas) . ' registros.');
}