当前位置: 首页>>代码示例>>PHP>>正文


PHP Helper\ProgressBar类代码示例

本文整理汇总了PHP中Symfony\Component\Console\Helper\ProgressBar的典型用法代码示例。如果您正苦于以下问题:PHP ProgressBar类的具体用法?PHP ProgressBar怎么用?PHP ProgressBar使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ProgressBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $desde = (int) $input->getArgument('desde');
     $output->writeln('Importando actividades...');
     $cantidad = 100;
     $progress = null;
     $importador = new ImportadorActividades($this->getContainer(), $this->getContainer()->get('doctrine')->getManager());
     $importador->Inicializar();
     $progress = new ProgressBar($output, $importador->ObtenerCantidadTotal());
     $progress->start();
     $ResultadoFinal = new ResultadoImportacion($importador);
     while (true) {
         $resultado = $importador->Importar($desde, $cantidad);
         $ResultadoFinal->AgregarContadoresLote($resultado);
         $progress->setProgress($resultado->PosicionCursor());
         if (!$resultado->HayMasRegistros()) {
             break;
         }
         $desde += $cantidad;
     }
     $progress->finish();
     $output->writeln('');
     $importador->RecalcularParent($output);
     $output->writeln(' Se importaron   ' . $ResultadoFinal->RegistrosNuevos . ' registros nuevos.');
     $output->writeln(' Se actualizaron ' . $ResultadoFinal->RegistrosActualizados . ' registros.');
     $output->writeln(' Se ignoraron    ' . $ResultadoFinal->RegistrosIgnorados . ' registros.');
     $output->writeln('Importación finalizada, se procesaron ' . $ResultadoFinal->TotalRegistrosProcesados() . ' registros.');
 }
开发者ID:Drake86cnf,项目名称:yacare,代码行数:28,代码来源:ImportarActividadesCommand.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $constraintDescriber = new \RestSpec\Output\ConstraintDescriber();
     $consoleOutput = new \RestSpec\Output\ConsoleOutput($output, $constraintDescriber);
     $validator = new \RestSpec\Validator\Rest();
     $loader = new \RestSpec\Loader();
     $loader->run();
     try {
         $useCaseFilter = $input->getArgument('filter');
         $api = $input->getOption('api');
         $restSpec = Spec\Rest::getInstance();
         $restSpecValidator = new \RestSpec\Spec\Validator();
         $restSpecValidator->validate($restSpec);
         $progressBar = new ProgressBar($output);
         $progressBar->setFormat('Testing your API specs. Already tested: %current% use cases [%bar%]');
         $progressBar->start();
         $validator->progress(function ($useCases) use($output, $progressBar) {
             $progressBar->advance();
         });
         $report = $validator->validate($restSpec, $api, $useCaseFilter);
         $progressBar->finish();
         $output->write($report->dumpAsConsoleText($api, $useCaseFilter));
         if ($report->getTotalUseCases() === 0 || $report->getUseCasesFailedCount() > 0) {
             exit(1);
         } else {
             exit(0);
         }
     } catch (\Exception $e) {
         $log = join("\n", $validator->getLog());
         $consoleOutput->getOutput()->writeln(sprintf("\n<error>Whoops! Some unexpected error occured. Validation log dump:\n\n%s\n\nThe exception type is: %s, and a message is following:</error>", $log, get_class($e)));
         $consoleOutput->errorHandler($e, 2);
     }
 }
开发者ID:talkrz,项目名称:rest-spec,代码行数:33,代码来源:RunCommand.php

示例3: 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();
 }
开发者ID:24eme,项目名称:aurouze,代码行数:28,代码来源:ContratUpdateMvtsCommand.php

示例4: execute

 function execute(InputInterface $input, OutputInterface $output)
 {
     $parameters = $this->extractArgumentsAndOptions($input);
     //如果当前目录下有配置文件自动加载配置文件
     if (is_file($configFile = getcwd() . DIRECTORY_SEPARATOR . self::CONFIG_FILE)) {
         $data = json_decode(file_get_contents($configFile), true);
         $parameters = array_merge($parameters, $data);
     }
     call_user_func_array([$this, 'initializeCollector'], $parameters);
     $this->collector->getDispatcher()->bind(Collector::EVENT_CAPTURE_URL_REPOSITORY, function (Event $event) use($output) {
         $repository = $event->getArgument('repository');
         $output->writeln(PHP_EOL);
         $output->writeln($repository->getUrl()->getUrlString());
         $progressBar = new ProgressBar($output, 100);
         $progressBar->start();
         $repository->getUrl()->setParameter('progressBar', $progressBar);
     });
     $this->collector->getDispatcher()->bind(Collector::EVENT_CAPTURED_URL_REPOSITORY, function (Event $event) use($output) {
         $repository = $event->getArgument('repository');
         $progressBar = $repository->getUrl()->getParameter('progressBar');
         $progressBar->advance(50);
         $progressBar->finish();
     });
     $this->collector->run();
 }
开发者ID:slince,项目名称:template-collector,代码行数:25,代码来源:CommandUI.php

示例5: execute

 /**
  * (non-PHPdoc)
  *
  * @see \Symfony\Component\Console\Command\Command::execute()
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $document = $this->getDocument($input->getArgument('document'));
     $items = $document->getElement();
     $directory = sprintf($input->getArgument('elementOutput'), $document->getFileInfo()->getBasename('.dtd'));
     $namespace = sprintf($input->getArgument('elementNamespace'), $document->getFileInfo()->getBasename('.dtd'));
     $parentClass = $input->getArgument('elementParentClass');
     $description = str_replace("\\", " ", $namespace);
     if (!file_exists($directory)) {
         mkdir($directory, 0777, true);
     }
     $progressBar = new ProgressBar($output, $items->count());
     $progressBar->setFormat('verbose');
     foreach ($items as $item) {
         $name = sprintf("%sElement", Source::camelCase($item->getName()));
         $filename = sprintf("%s/%s.php", $directory, $name);
         $classDescription = sprintf("%s %s", $description, $name);
         $datetime = new \DateTime();
         $properties = array((new PropertyGenerator("name", $item->getName()))->setDocBlock(new DocBlockGenerator(sprintf("%s Name", $classDescription), "", array(new Tag("var", "string")))), (new PropertyGenerator("value", $item->getValue()))->setDocBlock(new DocBlockGenerator(sprintf("%s Value", $classDescription), "", array(new Tag("var", "string")))));
         $docblock = new DocBlockGenerator($classDescription, "", array(new Tag("author", "ITC Generator " . $datetime->format("d.m.Y h:m:s")), new Tag("copyright", "LGPL")));
         $fileGenerator = new FileGenerator();
         $fileGenerator->setClass(new ClassGenerator($name, $namespace, null, $parentClass, array(), $properties, array(), $docblock));
         file_put_contents($filename, $fileGenerator->generate());
         $progressBar->advance();
     }
     $progressBar->finish();
 }
开发者ID:slavomirkuzma,项目名称:itc-bundle,代码行数:32,代码来源:Element.php

示例6: download

 /**
  * Download
  */
 protected function download(OutputInterface &$output, $from, $to)
 {
     $output->writeln('Download ' . $from);
     $progress = new ProgressBar($output);
     $progress->setFormat('normal_nomax');
     $step = 0;
     $ctx = stream_context_create(array(), array('notification' => function ($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) use($output, $progress, &$step) {
         switch ($notification_code) {
             case STREAM_NOTIFY_FILE_SIZE_IS:
                 $progress->start(100);
                 break;
             case STREAM_NOTIFY_PROGRESS:
                 $newStep = round($bytes_transferred / $bytes_max * 100);
                 if ($newStep > $step) {
                     $step = $newStep;
                     $progress->setProgress($step);
                 }
                 break;
         }
     }));
     $file = file_get_contents($from, false, $ctx);
     $progress->finish();
     file_put_contents($to, $file);
     $output->writeln('');
     return $to;
 }
开发者ID:timiki,项目名称:geonames-bundle,代码行数:29,代码来源:GeonamesCommand.php

示例7: parse

 public function parse($output)
 {
     $trlElements = array();
     $fileCount = iterator_count($this->_fileFinder);
     $output->writeln('Twig-Files:');
     $progress = new ProgressBar($output, $fileCount);
     $twig = $this->_createKwfTwigEnvironment();
     foreach ($this->_fileFinder as $file) {
         $nodes = $twig->parse($twig->tokenize(file_get_contents($file->getRealpath()), $file->getRealpath()));
         $trlElementsFromFile = array();
         //Recursively loop through the AST
         foreach ($nodes as $child) {
             if ($child instanceof \Twig_Node) {
                 $trlElementsFromFile = $this->_process($child, $trlElementsFromFile);
             }
         }
         foreach ($trlElementsFromFile as $trlElement) {
             $trlElement['file'] = $file->getRealpath();
             $trlElements[] = $trlElement;
         }
         $progress->advance();
     }
     $progress->finish();
     $output->writeln('');
     return $trlElements;
 }
开发者ID:koala-framework,项目名称:kwf-trl,代码行数:26,代码来源:ParseTwigForTrl.php

示例8: execute

 /**
  * {@inheritdoc}
  *
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $jobId = $this->stdIn->getArgument('job');
     $job = $this->client->getPiftJob($jobId);
     $issue = $this->client->getNode($job->get('issue_nid'));
     $this->stdOut->writeln("<comment>" . $issue->get('title') . "</comment>");
     $progress = new ProgressBar($this->stdOut);
     $progress->start();
     if ($job->get('status') == 'complete') {
         $progress->advance();
     } else {
         while ($job->get('status') != 'complete') {
             $progress->advance();
             sleep(60);
             $job = $this->client->getPiftJob($jobId);
         }
     }
     $progress->finish();
     $this->sendNotification('DrupalCI', "DrupalCI test {$jobId} completed");
     $this->stdOut->writeln('');
     $table = new Table($this->stdOut);
     $table->setHeaders(['Job ID', 'Patch', 'Status', 'Result']);
     $patch = $this->client->getFile($job->get('file_id'));
     if ($job->get('result') == 'pass') {
         $style = 'info';
     } elseif ($job->get('result') == 'fail') {
         $style = 'error';
     } else {
         $style = 'comment';
     }
     $table->addRow([$job->get('job_id'), $patch->get('name'), $job->get('status'), "<{$style}>" . $job->get('message') . "</{$style}>"]);
     $table->render();
 }
开发者ID:mglaman,项目名称:drupalorg-cli,代码行数:37,代码来源:Watch.php

示例9: execute

 /**
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fileIterator = new File_Iterator_Facade();
     $files = $input->getArgument('target');
     $files = $fileIterator->getFilesAsArray($files, '.php');
     $extractor = new Extractor();
     $results = [];
     $progress = new ProgressBar($output, count($files));
     foreach ($files as $file) {
         $results[$file] = $extractor->file($file);
         $progress->advance();
     }
     $progress->clear();
     $namespaces = [];
     foreach ($results as $file => $result) {
         foreach ($result as $dependency) {
             $namespaces[$dependency][] = $file;
         }
     }
     ksort($namespaces);
     $output->writeln('');
     // line break (due to the progress bar not completely clearing out)
     if ($input->getOption('why')) {
         foreach ($namespaces as $namespace => $files) {
             $output->writeln($namespace);
             foreach ($files as $file) {
                 $output->writeln("\t" . $file);
             }
         }
     } else {
         foreach (array_keys($namespaces) as $namespace) {
             $output->writeln($namespace);
         }
     }
 }
开发者ID:tomzx,项目名称:php-dependency-extractor,代码行数:39,代码来源:ExtractCommand.php

示例10: execute

 /**
  * Método que ejecuta el comando.
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return String con los nombres de los usuarios que han sido eliminados                 
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     //se utiliza el manager de Symfony
     $em = $this->getContainer()->get('doctrine.orm.entity_manager');
     //se utiliza el manager de FOS
     $um = $this->getContainer()->get('fos_user.user_manager');
     //buscar todos los usuarios
     $usuarios = $em->getRepository('UserBundle:Usuario')->findAll();
     $UsuariosEliminados = ' ';
     $cantidadUsuarios = count($usuarios);
     //contador todos los usuarios a evaluar
     //Mostrar Progreso de todos los usuarios evaluados
     $progress = new ProgressBar($output, $cantidadUsuarios);
     $progress->start();
     foreach ($usuarios as $usuario) {
         //si no ha sido confirmado esta variable es NULL
         if (is_null($usuario->getLastLogin())) {
             $um->deleteUser($usuario);
             //eliminar Usuario
             $UsuariosEliminados = $UsuariosEliminados . ' ' . $usuario->getUsername() . '\\n';
         }
         $progress->advance();
     }
     //terminar barra de progreso
     $progress->finish();
     $output->writeln($UsuariosEliminados);
 }
开发者ID:Newton-Labs,项目名称:Learn-in-UDV,代码行数:35,代码来源:DropNonActiveUserCommand.php

示例11: 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);
 }
开发者ID:Pandahisham,项目名称:topsort.php,代码行数:26,代码来源:BenchmarkCommand.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->configuration = $this->getHelperSet()->get('configuration')->getConfiguration();
     $this->entityManager = $this->getHelperSet()->get('em')->getEntityManager();
     $this->questionHelper = $this->getHelperSet()->get('question');
     if (!empty($this->configuration['assetsProcessing']['maxPixelSize']) && $this->configuration['assetsProcessing']['maxPixelSize'] > 0) {
         $this->downscaler = new DownscaleImageManager($this->entityManager, null, $this->configuration['assetsProcessing']['driver'], $this->configuration['assetsProcessing']['maxPixelSize']);
         $confirmation = new ConfirmationQuestion('<question>Are you sure to downscale all your image documents to ' . $this->configuration['assetsProcessing']['maxPixelSize'] . 'px?</question>', false);
         if ($this->questionHelper->ask($input, $output, $confirmation)) {
             $documents = $this->entityManager->getRepository('RZ\\Roadiz\\Core\\Entities\\Document')->findBy(['mimeType' => ['image/png', 'image/jpeg', 'image/gif', 'image/tiff'], 'raw' => false]);
             $progress = new ProgressBar($output, count($documents));
             $progress->setFormat('verbose');
             $progress->start();
             foreach ($documents as $document) {
                 $this->downscaler->processDocumentFromExistingRaw($document);
                 $progress->advance();
             }
             $progress->finish();
             $text = PHP_EOL . '<info>Every documents have been downscaled, a raw version has been kept.</info>' . PHP_EOL;
             /*
              * Clear cache documents
              */
             $assetsClearer = new AssetsClearer();
             $assetsClearer->clear();
             $text .= $assetsClearer->getOutput() . PHP_EOL;
         }
     } else {
         $text = '<info>Your configuration is not set for downscaling documents.</info>' . PHP_EOL;
         $text .= 'Add <info>assetsProcessing.maxPixelSize</info> parameter in your <info>config.yml</info> file.' . PHP_EOL;
     }
     $output->writeln($text);
 }
开发者ID:QuangDang212,项目名称:roadiz,代码行数:32,代码来源:DocumentDownscaleCommand.php

示例13: fire

 public function fire()
 {
     if (!$this->option('verbose')) {
         $this->output = new NullOutput();
     }
     $this->call('search:clear');
     /** @var Search $search */
     $search = App::make('search');
     $modelRepositories = $search->config()->repositories();
     if (count($modelRepositories) > 0) {
         foreach ($modelRepositories as $modelRepository) {
             $this->info('Creating index for model: "' . get_class($modelRepository) . '"');
             $count = $modelRepository->count();
             if ($count === 0) {
                 $this->comment(' No available models found. ');
                 continue;
             }
             $progress = new ProgressBar($this->getOutput(), $count);
             $progress->start();
             $modelRepository->chunk(1000, function ($chunk) use($progress, $search) {
                 foreach ($chunk as $model) {
                     $search->update($model);
                     $progress->advance();
                 }
             });
             $progress->finish();
         }
         $this->info(PHP_EOL . 'Operation is fully complete!');
     } else {
         $this->error('No models found in config.php file..');
     }
 }
开发者ID:cmoralesweb,项目名称:laravel-lucene-search,代码行数:32,代码来源:RebuildCommand.php

示例14: waitMultiple

 /**
  * Wait for multiple activities to complete.
  *
  * @param Activity[]      $activities
  * @param OutputInterface $output
  */
 public static function waitMultiple(array $activities, OutputInterface $output)
 {
     $count = count($activities);
     if ($count <= 0) {
         return;
     }
     $complete = 0;
     $output->writeln("Waiting...");
     $bar = new ProgressBar($output);
     $bar->start($count);
     $bar->setFormat('verbose');
     while ($complete < $count) {
         sleep(1);
         foreach ($activities as $activity) {
             if (!$activity->isComplete()) {
                 $activity->refresh();
             } else {
                 $complete++;
             }
         }
         $bar->setProgress($complete);
     }
     $bar->finish();
     $output->writeln('');
 }
开发者ID:ratajczak,项目名称:platformsh-cli,代码行数:31,代码来源:ActivityUtil.php

示例15: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $checksums = json_decode($this->fileChecksums, true);
     $root = __DIR__ . '/../';
     $progressbar = new ProgressBar($output, count($checksums));
     $errors = [];
     $missing = [];
     foreach ($checksums as $file => $checksum) {
         $progressbar->advance();
         $absPath = Path::normalize($root . $file);
         if (!file_exists($absPath)) {
             $missing[] = $absPath;
         } elseif (md5(file_get_contents($absPath)) !== $checksum) {
             $errors[] = $absPath;
         }
     }
     $output->writeln("\n");
     if (count($errors) > 0 || count($missing) > 0) {
         foreach ($missing as $path) {
             $output->writeln('<error>Missing file:</error> ' . $path);
         }
         foreach ($errors as $path) {
             $output->writeln('<error>Invalid checksum:</error> ' . $path);
         }
         $output->writeln("\nYour News installation does not " . 'match the recorded files and versions. This ' . 'is either caused by missing or old files or an ' . 'invalid or out of date appinfo/checksum.json ' . 'file.');
         $output->writeln('Either way, please make sure that the contents ' . 'of the News app\'s directory match the ' . 'contents of the installed tarball.');
         return 1;
     } else {
         $output->writeln('<info>Installation verified, everything OK!' . '</info>');
     }
 }
开发者ID:nrbrt,项目名称:news,代码行数:31,代码来源:verifyinstall.php


注:本文中的Symfony\Component\Console\Helper\ProgressBar类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。