本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例7: create
public static function create(OutputInterface $output)
{
return $output instanceof StreamOutput ? new StreamHandler($output->getStream()) : new self($output);
}
示例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);
}
示例9: getOutput
/**
* @return string
*/
protected function getOutput()
{
rewind($this->output->getStream());
return stream_get_contents($this->output->getStream());
}