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


PHP SymfonyStyle::comment方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Style\SymfonyStyle::comment方法的典型用法代码示例。如果您正苦于以下问题:PHP SymfonyStyle::comment方法的具体用法?PHP SymfonyStyle::comment怎么用?PHP SymfonyStyle::comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Style\SymfonyStyle的用法示例。


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $pools = array();
     $clearers = array();
     $container = $this->getContainer();
     $cacheDir = $container->getParameter('kernel.cache_dir');
     foreach ($input->getArgument('pools') as $id) {
         $pool = $container->get($id);
         if ($pool instanceof CacheItemPoolInterface) {
             $pools[$id] = $pool;
         } elseif ($pool instanceof Psr6CacheClearer) {
             $clearers[$id] = $pool;
         } else {
             throw new \InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
         }
     }
     foreach ($clearers as $id => $clearer) {
         $io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
         $clearer->clear($cacheDir);
     }
     foreach ($pools as $id => $pool) {
         $io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
         $pool->clear();
     }
     $io->success('Cache was successfully cleared.');
 }
开发者ID:ayoah,项目名称:symfony,代码行数:30,代码来源:CachePoolClearCommand.php

示例2: execute

 /**
  *
  * {@inheritdoc}
  *
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputIsVerbose = $output->isVerbose();
     $io = new SymfonyStyle($input, $output);
     $realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
     // the old cache dir name must not be longer than the real one to avoid exceeding
     // the maximum length of a directory or file path within it (esp. Windows MAX_PATH)
     $oldCacheDir = substr($realCacheDir, 0, -1) . ('~' === substr($realCacheDir, -1) ? '+' : '~');
     $filesystem = $this->getContainer()->get('filesystem');
     if (!is_writable($realCacheDir)) {
         throw new \RuntimeException(sprintf('Unable to write in the "%s" directory', $realCacheDir));
     }
     if ($filesystem->exists($oldCacheDir)) {
         $filesystem->remove($oldCacheDir);
     }
     $kernel = $this->getContainer()->get('kernel');
     $io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
     $this->getContainer()->get('cache_clearer')->clear($realCacheDir);
     if ($input->getOption('no-warmup')) {
         $filesystem->rename($realCacheDir, $oldCacheDir);
     } else {
         // the warmup cache dir name must have the same length than the real one
         // to avoid the many problems in serialized resources files
         $realCacheDir = realpath($realCacheDir);
         $warmupDir = substr($realCacheDir, 0, -1) . ('_' === substr($realCacheDir, -1) ? '-' : '_');
         if ($filesystem->exists($warmupDir)) {
             if ($outputIsVerbose) {
                 $io->comment('Clearing outdated warmup directory...');
             }
             $filesystem->remove($warmupDir);
         }
         if ($outputIsVerbose) {
             $io->comment('Warming up cache...');
         }
         $this->warmup($warmupDir, $realCacheDir, !$input->getOption('no-optional-warmers'));
         $filesystem->rename($realCacheDir, $oldCacheDir);
         if ('\\' === DIRECTORY_SEPARATOR) {
             sleep(1);
             // workaround for Windows PHP rename bug
         }
         $filesystem->rename($warmupDir, $realCacheDir);
     }
     if ($outputIsVerbose) {
         $io->comment('Removing old cache directory...');
     }
     $filesystem->remove($oldCacheDir);
     if ($outputIsVerbose) {
         $io->comment('Finished');
     }
     $io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
 }
开发者ID:skelpo,项目名称:framework,代码行数:56,代码来源:CacheClearCommand.php

示例3: loadConfiguration

 /**
  * Loads the local configuration from "~/.localhook/config.json" file.
  */
 protected function loadConfiguration()
 {
     try {
         $configuration = $this->configurationStorage->loadFromFile()->get();
     } catch (NoConfigurationException $e) {
         $this->io->comment($e->getMessage());
         if (!$this->secret) {
             $this->secret = $this->io->ask('Secret');
         }
         $configuration = $this->parseConfigurationKey();
     }
     $this->serverUrl = $configuration['socket_url'];
     $this->secret = $configuration['secret'];
     $this->configurationStorage->merge($configuration)->save();
 }
开发者ID:localhook,项目名称:localhook,代码行数:18,代码来源:AbstractCommand.php

示例4: simulate

 /**
  * @param string $username
  * @param string $endpoint
  *
  * @param string $method
  * @param array  $query
  * @param array  $headers
  * @param string $body
  *
  * @return mixed|ResponseInterface
  */
 public function simulate($username, $endpoint, $method = 'POST', $query = ['get_param_1' => 'get_value_1', 'get_param_2' => 'get_value_2'], $headers = ['My-Header' => 'MyHeaderValue'], $body = 'post_param_1=post_value_1&post_param_2=post_value_2')
 {
     $url = $this->router->generate('notifications', array_merge(['username' => $username, 'endpoint' => $endpoint], $query));
     if ($this->io) {
         $this->io->comment('URL: ' . $url);
     }
     $server = [];
     if ($this->requestStack && ($currentRequest = $this->requestStack->getCurrentRequest())) {
         $server = $currentRequest->server->all();
     }
     $request = Request::create($url, $method, [], [], [], $server, $body);
     $request->headers->replace($headers);
     $response = $this->kernel->handle($request, HttpKernelInterface::SUB_REQUEST);
     return $response;
 }
开发者ID:localhook,项目名称:localhook-server,代码行数:26,代码来源:RequestSimulator.php

示例5: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->comment("Warming up the cache (<info>{$this->cacheDir}</info>)");
     $this->cacheWarmer->warmup($this->cacheDir);
     $io->success('Cache warmed up');
 }
开发者ID:gnugat,项目名称:micro-framework-bundle,代码行数:10,代码来源:CacheWarmupCommand.php

示例6: outputMailer

 /**
  * @throws \InvalidArgumentException When route does not exist
  */
 protected function outputMailer($name)
 {
     try {
         $service = sprintf('swiftmailer.mailer.%s', $name);
         $mailer = $this->getContainer()->get($service);
     } catch (ServiceNotFoundException $e) {
         throw new \InvalidArgumentException(sprintf('The mailer "%s" does not exist.', $name));
     }
     $tableHeaders = array('Property', 'Value');
     $tableRows = array();
     $transport = $mailer->getTransport();
     $spool = $this->getContainer()->getParameter(sprintf('swiftmailer.mailer.%s.spool.enabled', $name)) ? 'YES' : 'NO';
     $delivery = $this->getContainer()->getParameter(sprintf('swiftmailer.mailer.%s.delivery.enabled', $name)) ? 'YES' : 'NO';
     $singleAddress = $this->getContainer()->getParameter(sprintf('swiftmailer.mailer.%s.single_address', $name));
     $this->io->title(sprintf('Configuration of the Mailer "%s"', $name));
     if ($this->isDefaultMailer($name)) {
         $this->io->comment('This is the default mailer');
     }
     $tableRows[] = array('Name', $name);
     $tableRows[] = array('Service', $service);
     $tableRows[] = array('Class', get_class($mailer));
     $tableRows[] = array('Transport', sprintf('%s (%s)', sprintf('swiftmailer.mailer.%s.transport.name', $name), get_class($transport)));
     $tableRows[] = array('Spool', $spool);
     if ($this->getContainer()->hasParameter(sprintf('swiftmailer.spool.%s.file.path', $name))) {
         $tableRows[] = array('Spool file', $this->getContainer()->getParameter(sprintf('swiftmailer.spool.%s.file.path', $name)));
     }
     $tableRows[] = array('Delivery', $delivery);
     $tableRows[] = array('Single Address', $singleAddress);
     $this->io->table($tableHeaders, $tableRows);
 }
开发者ID:symfony,项目名称:swiftmailer-bundle,代码行数:33,代码来源:DebugCommand.php

示例7: execCmd

 /**
  * @param string $cmd
  * @param bool   $ignoreErrors
  *
  * @throws Exception
  */
 private function execCmd($cmd, $ignoreErrors = false)
 {
     $cmd = 'cd ' . $this->workspacePath . ' && ' . $cmd;
     if ($this->io->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $this->io->comment($cmd);
     }
     $process = new Process($cmd);
     $process->run(function ($type, $buffer) use($ignoreErrors) {
         if (Process::ERR === $type) {
             if ($ignoreErrors) {
                 if ($this->io->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                     $this->io->comment($buffer);
                 }
             } else {
                 $this->io->error($buffer);
             }
         } else {
             if ($this->io->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
                 $this->io->comment($buffer);
             }
         }
     });
     if (!$ignoreErrors && !$process->isSuccessful()) {
         throw new Exception($process->getOutput() . $process->getErrorOutput());
     }
 }
开发者ID:lucascherifi,项目名称:gitaski,代码行数:32,代码来源:GitProcessor.php

示例8: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $address = $input->getArgument('address');
     if (strpos($address, ':') === false) {
         $address .= ':' . $input->getOption('port');
     }
     if ($this->isOtherServerProcessRunning($address)) {
         $io->error(sprintf('A process is already listening on http://%s', $address));
         return 1;
     }
     $webDir = $this->app['resources']->getPath('web');
     $router = $webDir . '/index.php';
     $io->success(sprintf('Server running on http://%s', $address));
     $io->comment('Quit the server with CONTROL-C.');
     if (($process = $this->createServerProcess($io, $address, $webDir, $router)) === null) {
         return 1;
     }
     /** @var ProcessHelper $helper */
     $helper = $this->getHelper('process');
     $helper->run($output, $process, null, null, OutputInterface::VERBOSITY_VERBOSE);
     if (!$process->isSuccessful()) {
         $errorMessages = ['Built-in server terminated unexpectedly.'];
         if ($process->isOutputDisabled()) {
             $errorMessages[] = 'Run the command again with -v option for more details.';
         }
         $io->error($errorMessages);
     }
     return $process->getExitCode();
 }
开发者ID:robbert-vdh,项目名称:bolt,代码行数:33,代码来源:ServerRun.php

示例9: execute

 /**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration.');
         $io->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $configuration = $extension->getConfiguration(array(), $this->getContainerBuilder());
     $this->validateConfiguration($extension, $configuration);
     if ($name === $extension->getAlias()) {
         $message = sprintf('Default configuration for extension with alias: "%s"', $name);
     } else {
         $message = sprintf('Default configuration for "%s"', $name);
     }
     switch ($input->getOption('format')) {
         case 'yaml':
             $io->writeln(sprintf('# %s', $message));
             $dumper = new YamlReferenceDumper();
             break;
         case 'xml':
             $io->writeln(sprintf('<!-- %s -->', $message));
             $dumper = new XmlReferenceDumper();
             break;
         default:
             $io->writeln($message);
             throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
     }
     $io->writeln($dumper->dump($configuration, $extension->getNamespace()));
 }
开发者ID:alekitto,项目名称:symfony,代码行数:38,代码来源:ConfigDumpReferenceCommand.php

示例10: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->caution('The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.');
     }
     $name = $input->getArgument('name');
     if (empty($name)) {
         $output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $output->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $output->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $output->title(sprintf('Current configuration for "%s"', $name));
     }
     $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
开发者ID:Kyra2778,项目名称:AMR,代码行数:31,代码来源:ConfigDebugCommand.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->comment("Clearing the cache (<info>{$this->cacheDir}</info>)");
     $this->cacheClearer->clear($this->cacheDir);
     $io->success('Cache cleared');
 }
开发者ID:gnugat,项目名称:micro-framework-bundle,代码行数:10,代码来源:CacheClearCommand.php

示例12: updateCode

 /**
  * @param SymfonyStyle|null $io
  */
 public function updateCode(SymfonyStyle $io = null)
 {
     $io->title('CampaignChain Data Update');
     if (empty($this->versions)) {
         $io->warning('No code updater Service found, maybe you didn\'t enable a bundle?');
         return;
     }
     $io->comment('The following data versions will be updated');
     $migratedVersions = array_map(function (DataUpdateVersion $version) {
         return $version->getVersion();
     }, $this->em->getRepository('CampaignChainUpdateBundle:DataUpdateVersion')->findAll());
     $updated = false;
     foreach ($this->versions as $version => $class) {
         if (in_array($version, $migratedVersions)) {
             continue;
         }
         $io->section('Version ' . $class->getVersion());
         $io->listing($class->getDescription());
         $io->text('Begin data update');
         $result = $class->execute($io);
         if ($result) {
             $dbVersion = new DataUpdateVersion();
             $dbVersion->setVersion($version);
             $this->em->persist($dbVersion);
             $this->em->flush();
             $io->text('Data update finished');
         }
         $updated = true;
     }
     if (!$updated) {
         $io->success('All data is up to date.');
     } else {
         $io->success('Every data version has been updated.');
     }
 }
开发者ID:campaignchain,项目名称:update,代码行数:38,代码来源:DataUpdateService.php

示例13: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $io->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $io->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $io->title(sprintf('Current configuration for "%s"', $name));
     }
     $io->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
开发者ID:xingshanghe,项目名称:symfony,代码行数:28,代码来源:ConfigDebugCommand.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Slack receive');
     $io->comment('Requesting slack websocket…');
     $latest = null;
     try {
         $latest = $this->container->get('doctrine')->getRepository(ProcessedSlackMessage::class)->findMostRecent();
     } catch (NoResultException $e) {
         $io->error('No message found in base, you should import first.');
         return;
     }
     $slack = $this->container->get('slack.api');
     $channelId = $slack->findChannelId($this->container->getParameter('slack_web_channel'));
     $response = $slack->request('rtm.start');
     $io->comment('Socket URL received, connecting…');
     $ws = new Client(json_decode($response)->url);
     $io->comment('Connected.');
     $exit = function ($sig) use($ws, $io) {
         $io->comment('Received closing signal ' . $sig);
         $ws->close();
         $io->comment('Exiting.');
         return;
     };
     foreach ([SIGTERM, SIGINT, SIGQUIT, SIGHUP] as $sig) {
         pcntl_signal($sig, $exit);
     }
     $ws->setTimeout(20);
     $pingId = 1;
     while (true) {
         try {
             pcntl_signal_dispatch();
             $this->receive($ws, $channelId, $io, $latest);
         } catch (ConnectionException $e) {
             $io->note('Sending Ping…');
             $ws->send(json_encode(['id' => $pingId, 'type' => 'ping']));
             if (!$this->isPong($ws->receive())) {
                 break;
             }
             ++$pingId;
         }
     }
     $ws->close();
 }
开发者ID:un-zero-un,项目名称:Veilleur,代码行数:44,代码来源:SlackReceiveCommand.php

示例15: 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.');
 }
开发者ID:un-zero-un,项目名称:Veilleur,代码行数:41,代码来源:SlackImportCommand.php


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