本文整理汇总了PHP中Symfony\Component\Console\Style\SymfonyStyle::progressFinish方法的典型用法代码示例。如果您正苦于以下问题:PHP SymfonyStyle::progressFinish方法的具体用法?PHP SymfonyStyle::progressFinish怎么用?PHP SymfonyStyle::progressFinish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Style\SymfonyStyle
的用法示例。
在下文中一共展示了SymfonyStyle::progressFinish方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clearCache
private function clearCache(SymfonyStyle $io, $env)
{
$io->section("Clearing cache ({$env})...");
$io->progressStart(1);
$input = $this->getEnvsInput($env);
$command = $this->getApplication()->find('cache:clear');
$cmdOutput = new BufferedOutput();
$returnCode = $command->run($input, $cmdOutput);
if ($returnCode !== 0) {
$io->error("cache:clear command failed. You may need to manually delete the cache folders.");
return;
}
$io->progressFinish();
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$io->title('Slack import');
$io->comment('Requesting slack history…');
$om = $this->container->get('doctrine')->getManager();
$slack = $this->container->get('slack.api');
$args = ['channel' => $slack->findChannelId($this->container->getParameter('slack_web_channel')), 'count' => 1000];
try {
$latest = $om->getRepository(ProcessedSlackMessage::class)->findMostRecent();
$args['oldest'] = $latest->getDate()->format('U.u');
} catch (NoResultException $e) {
}
$response = $slack->request('channels.history', $args);
$messages = json_decode($response)->messages;
$io->progressStart(count($messages));
foreach ($messages as $message) {
$io->progressAdvance();
if (!(new AndX(new IsSlackMessage(), new IsHumanMessage()))->isSatisfiedBy($message)) {
continue;
}
try {
$url = $this->container->get('parser.slack_message')->parseUrl($message->text);
$tags = $this->container->get('parser.slack_message')->parseTags($message->text);
$watchLink = $this->container->get('extractor.watch_link_metadata')->extract($url, $tags);
$watchLink->setCreatedAt((new \DateTime())->setTimestamp($message->ts));
$processedMessage = new ProcessedSlackMessage($watchLink->getCreatedAt());
$om->persist($processedMessage);
$om->persist($watchLink);
// Flush required at each round for tags unicity
$om->flush();
} catch (\InvalidArgumentException $e) {
$this->container->get('logger')->addNotice('Unable to insert watchlink', ['exception' => $e, 'message' => $message->text]);
} catch (\Exception $e) {
$this->container->get('logger')->addError('Unknow exception', ['exception' => $e, 'message' => $message->text]);
}
}
$io->progressFinish();
$io->comment('Flush links…');
$io->comment('Done.');
}
示例3: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$finder = new Finder();
$finder->in(sys_get_temp_dir())->ignoreUnreadableDirs()->sortByType();
$fs = new Filesystem();
$files = $finder->name("backup_*");
if (count($files) == 0) {
$io->success('No olders backups removed');
return;
}
$io->progressStart(count($files));
foreach ($files as $file) {
if ($fs->exists($file->getRealpath())) {
$fs->remove($file->getRealpath());
}
sleep(1);
$io->progressAdvance();
}
$io->progressFinish();
}
示例4: createServerManagers
private function createServerManagers()
{
/** @var Discord $discord */
/* @var ObjectManager $manager */
$discord = $this->getContainer()->get('discord');
$manager = $this->getContainer()->get('default_manager');
$repo = $manager->getRepository($this->getContainer()->getParameter('server_class'));
/** @var Collection $servers */
$servers = $discord->guilds;
$ids = [];
foreach ($discord->guilds as $guild) {
$ids[] = $guild->id;
}
$dbServers = $repo->findBy(['identifier' => $ids]);
$this->output->text('Creating server managers for ' . $servers->count() . ' servers.');
$this->output->progressStart($servers->count());
/** @var ServerManagerFactory $factory */
$factory = $this->getContainer()->get('factory.server_manager');
foreach ($discord->guilds as $server) {
$dbServer = $this->findDbServer($dbServers, $server);
try {
$this->serverManagers[] = $factory->create($server, $dbServer);
} catch (\Exception $e) {
$this->output->progressFinish();
$this->logError($e->getMessage());
exit(0);
}
$this->output->progressAdvance();
}
$this->output->progressFinish();
$delay = $this->getContainer()->getParameter('database_save_delay');
if ($delay !== false) {
$this->getContainer()->get('default_manager')->flush();
$discord->loop->addPeriodicTimer($delay, function () {
$this->output->note('Saving current UoW to database.');
$this->getContainer()->get('default_manager')->flush();
});
}
}
示例5: doGenerate
/**
* @return array
*/
private function doGenerate()
{
$numberOfChars = count($this->possibleChars) - 1;
$codesList = [];
$this->io->progressStart($this->numberOfCodesToGenerate);
for ($i = 0; $i < $this->numberOfCodesToGenerate; $i++) {
do {
$code = '';
for ($j = 0; $j < $this->codeLength; $j++) {
$code .= $this->possibleChars[rand(0, $numberOfChars)];
}
} while (isset($codesList[$code]));
$codesList[$code] = $code;
$this->io->progressAdvance();
if ($this->sleepTime) {
usleep($this->sleepTime);
}
}
$this->io->progressFinish();
if ($this->sort) {
sort($codesList);
}
return array_unique($codesList);
}
示例6: executeJobs
/**
* Search for open jobs and executes them
* then show a report about the done job.
*/
protected function executeJobs()
{
// Get the Jobs to be processed.
$jobsInQueue = $this->em->getRepository('CampaignChainCoreBundle:Job')->getOpenJobsForScheduler($this->scheduler);
if (empty($jobsInQueue)) {
return;
}
$this->io->section('Executing jobs now:');
$this->logger->info('Executing {counter} jobs now:', ['counter' => count($jobsInQueue)]);
$this->io->progressStart(count($jobsInQueue));
foreach ($jobsInQueue as $jobInQueue) {
// Execute job.
$this->executeJob($jobInQueue);
$this->io->progressAdvance();
}
// ensure that the progress bar is at 100%
$this->io->progressFinish();
$this->em->clear();
// Get the processed jobs.
$jobsProcessed = $this->em->getRepository('CampaignChainCoreBundle:Job')->getProcessedJobsForScheduler($this->scheduler);
if (empty($jobsProcessed)) {
return;
}
// Display the results of the execution.
$tableHeader = ['Job ID', 'Operation ID', 'Process ID', 'Job Name', 'Job Start Date', 'Job End Date', 'Duration', 'Status', 'Message'];
$outputTableRows = [];
foreach ($jobsProcessed as $jobProcessed) {
$startDate = null;
$endDate = null;
if ($jobProcessed->getStartDate()) {
$startDate = $jobProcessed->getStartDate()->format('Y-m-d H:i:s');
}
if ($jobProcessed->getEndDate()) {
$endDate = $jobProcessed->getEndDate()->format('Y-m-d H:i:s');
}
$jobData = [$jobProcessed->getId(), $jobProcessed->getActionId(), $jobProcessed->getPid(), $jobProcessed->getName(), $startDate, $endDate, $jobProcessed->getDuration() . ' ms', $jobProcessed->getStatus(), $jobProcessed->getMessage()];
$outputTableRows[] = $jobData;
if (Job::STATUS_ERROR === $jobProcessed->getStatus()) {
$context = array_combine($tableHeader, $jobData);
$this->logger->error($jobProcessed->getMessage(), $context);
}
}
$this->io->text('Results of executed actions:');
$this->io->table($tableHeader, $outputTableRows);
}
示例7: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
*
* @return void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io->title($this->getDescription());
$totalAuthorCount = $this->getAuthorCount();
$this->io->progressStart($totalAuthorCount);
$rsm = new ResultSetMapping();
for ($count = 0; $count <= $totalAuthorCount; $count += self::STEP) {
$sql = <<<SQL
UPDATE author
SET user_id = users.id
FROM users
WHERE author.email = users.email
AND author.id > ?
and author.id < ?
and author.user_id is null
SQL;
$query = $this->em->createNativeQuery($sql, $rsm);
$query->setParameter(1, $count);
$query->setParameter(2, $count + self::STEP);
$query->getResult();
if (self::STEP > $totalAuthorCount) {
$this->io->progressFinish();
} else {
$this->io->progressAdvance(self::STEP);
}
}
$this->io->newLine(2);
$this->io->success('All process finished');
}