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


PHP OutputInterface::getStream方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input);
     $environment = $this->getSelectedEnvironment();
     $limit = (int) $input->getOption('limit');
     $activities = $environment->getActivities($limit, $input->getOption('type'));
     if (!$activities) {
         $this->stdErr->writeln('No activities found');
         return 1;
     }
     $headers = array("ID", "Created", "Description", "% Complete", "Result");
     $rows = array();
     foreach ($activities as $activity) {
         $description = $activity->getDescription();
         $description = wordwrap($description, 40);
         $rows[] = array($activity['id'], date('Y-m-d H:i:s', strtotime($activity['created_at'])), $description, $activity->getCompletionPercent(), $activity->state);
     }
     if ($output instanceof StreamOutput && $input->getOption('pipe')) {
         $stream = $output->getStream();
         array_unshift($rows, $headers);
         foreach ($rows as $row) {
             fputcsv($stream, $row, "\t");
         }
         return 0;
     }
     $this->stdErr->writeln("Recent activities for the environment <info>" . $environment['id'] . "</info>");
     $table = new Table($output);
     $table->setHeaders($headers);
     $table->addRows($rows);
     $table->render();
     return 0;
 }
开发者ID:CompanyOnTheWorld,项目名称:platformsh-cli,代码行数:32,代码来源:ActivityListCommand.php

示例2: getDisplay

 /**
  * Gets the display returned by the last execution of the application.
  *
  * @param bool $normalize Whether to normalize end of lines to \n or not
  *
  * @return string The display
  */
 public function getDisplay($normalize = false)
 {
     rewind($this->output->getStream());
     $display = stream_get_contents($this->output->getStream());
     if ($normalize) {
         $display = str_replace(PHP_EOL, "\n", $display);
     }
     return $display;
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:16,代码来源:ApplicationTester.php

示例3: hasTty

 /**
  * Determine if reporter is reporting to a tty terminal
  *
  * @return bool
  */
 private function hasTty()
 {
     if (getenv("PERIDOT_TTY")) {
         return true;
     }
     $tty = function_exists('posix_isatty') && @posix_isatty($this->output->getStream());
     if ($tty) {
         putenv("PERIDOT_TTY=1");
     }
     return $tty;
 }
开发者ID:brianium,项目名称:peridot,代码行数:16,代码来源:AbstractBaseReporter.php

示例4: dump_output

 public function dump_output(OutputInterface $output_formatter)
 {
     $dump = '';
     if ($output_formatter instanceof StreamOutput) {
         $stream = $output_formatter->getStream();
         // rewind stream to read full contents
         rewind($stream);
         $dump = stream_get_contents($stream);
     } else {
         var_dump($output_formatter);
         throw new \Exception('Cannot dump output of type "' . get_class($output_formatter) . '"!');
     }
     return $dump;
 }
开发者ID:axenox,项目名称:PackageManager,代码行数:14,代码来源:AbstractComposerAction.php

示例5: render

 /**
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param array $rows
  */
 public function render(OutputInterface $output, array $rows)
 {
     if ($output instanceof StreamOutput) {
         $stream = $output->getStream();
     } else {
         $stream = \STDOUT;
     }
     $i = 0;
     foreach ($rows as $row) {
         if ($i++ == 0) {
             fputcsv($stream, array_keys($row));
         }
         fputcsv($stream, $row);
     }
 }
开发者ID:iMi-digital,项目名称:imi-conrun,代码行数:19,代码来源:CsvRenderer.php

示例6: render

 /**
  * {@inheritdoc}
  */
 public function render(OutputInterface $output, array $rows)
 {
     // no rows - there is nothing to do
     if (!$rows) {
         return;
     }
     if ($output instanceof StreamOutput) {
         $stream = $output->getStream();
     } else {
         $stream = \STDOUT;
     }
     fputcsv($stream, array_keys(reset($rows)));
     foreach ($rows as $row) {
         fputcsv($stream, $row);
     }
 }
开发者ID:jsiefer,项目名称:n98-magerun,代码行数:19,代码来源:CsvRenderer.php

示例7: create

 public static function create(OutputInterface $output)
 {
     return $output instanceof StreamOutput ? new StreamHandler($output->getStream()) : new self($output);
 }
开发者ID:metro-q,项目名称:metro,代码行数:4,代码来源:OutputHandler.php

示例8: isTerminal

 /**
  * Detect automatically whether the output is a TTY terminal.
  *
  * @param OutputInterface $output
  *
  * @return bool
  */
 protected function isTerminal(OutputInterface $output)
 {
     if (!$output instanceof StreamOutput) {
         return false;
     }
     // If the POSIX extension doesn't exist, default to true. It's better
     // for Windows users if we assume the output is a terminal.
     if (!function_exists('posix_isatty')) {
         return true;
     }
     // This uses the same test as StreamOutput::hasColorSupport().
     $stream = $output->getStream();
     /** @noinspection PhpParamsInspection */
     return @posix_isatty($stream);
 }
开发者ID:ecolinet,项目名称:platformsh-cli,代码行数:22,代码来源:CommandBase.php

示例9: getOutput

 /**
  * @return string
  */
 protected function getOutput()
 {
     rewind($this->output->getStream());
     return stream_get_contents($this->output->getStream());
 }
开发者ID:WeavingTheWeb,项目名称:devobs,代码行数:8,代码来源:ModerateIndexPopulationCommand.php


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