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


PHP OutputInterface::getVerbosity方法代码示例

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


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

示例1: execute

 /**
  * Execute command
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return bool
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $quiet = $output->getVerbosity() == OutputInterface::VERBOSITY_QUIET;
     $verbose = $output->getVerbosity() == OutputInterface::VERBOSITY_VERBOSE;
     if (!$quiet) {
         $output->write('<info>' . $this->getApplication()->getName() . '</info>');
         $output->write(' version <comment>' . $this->getApplication()->getVersion() . '</comment> ');
         $output->writeln("by J.Ginés Hernández G. <jgines@gmail.com>\n");
     }
     $sourcePath = $input->getArgument('source');
     $destPath = $input->getArgument('dest');
     $formatType = $input->getOption('format');
     $sortImg = new PhotoSort($verbose);
     $items = $sortImg->copy($sourcePath, $destPath, $formatType);
     if ($verbose) {
         if (count($items)) {
             $table = new Table($output);
             $table->setHeaders(array('Old File', 'New File'));
             $table->setRows($items);
             $table->render();
         }
         $output->writeln("\nCheers!\n");
     }
     return true;
 }
开发者ID:ginsen,项目名称:photosort,代码行数:33,代码来源:dirCopyCommand.php

示例2: run

 /**
  * Executes the application.
  *
  * Available options:
  *
  *  * interactive:               Sets the input interactive flag
  *  * decorated:                 Sets the output decorated flag
  *  * verbosity:                 Sets the output verbosity flag
  *  * capture_stderr_separately: Make output of stdOut and stdErr separately available
  *
  * @param array $input   An array of arguments and options
  * @param array $options An array of options
  *
  * @return int The command exit code
  */
 public function run(array $input, $options = array())
 {
     $this->input = new ArrayInput($input);
     if (isset($options['interactive'])) {
         $this->input->setInteractive($options['interactive']);
     }
     $this->captureStreamsIndependently = array_key_exists('capture_stderr_separately', $options) && $options['capture_stderr_separately'];
     if (!$this->captureStreamsIndependently) {
         $this->output = new StreamOutput(fopen('php://memory', 'w', false));
         if (isset($options['decorated'])) {
             $this->output->setDecorated($options['decorated']);
         }
         if (isset($options['verbosity'])) {
             $this->output->setVerbosity($options['verbosity']);
         }
     } else {
         $this->output = new ConsoleOutput(isset($options['verbosity']) ? $options['verbosity'] : ConsoleOutput::VERBOSITY_NORMAL, isset($options['decorated']) ? $options['decorated'] : null);
         $errorOutput = new StreamOutput(fopen('php://memory', 'w', false));
         $errorOutput->setFormatter($this->output->getFormatter());
         $errorOutput->setVerbosity($this->output->getVerbosity());
         $errorOutput->setDecorated($this->output->isDecorated());
         $reflectedOutput = new \ReflectionObject($this->output);
         $strErrProperty = $reflectedOutput->getProperty('stderr');
         $strErrProperty->setAccessible(true);
         $strErrProperty->setValue($this->output, $errorOutput);
         $reflectedParent = $reflectedOutput->getParentClass();
         $streamProperty = $reflectedParent->getProperty('stream');
         $streamProperty->setAccessible(true);
         $streamProperty->setValue($this->output, fopen('php://memory', 'w', false));
     }
     return $this->statusCode = $this->application->run($this->input, $this->output);
 }
开发者ID:Ener-Getick,项目名称:symfony,代码行数:47,代码来源:ApplicationTester.php

示例3: initHandlers

 protected function initHandlers(OutputInterface $output)
 {
     $this->output = $output;
     $this->formatter = $this->getHelperSet()->get('formatter');
     $this->is_verbose = $this->output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL;
     $this->logger = $this->getContainer()->get('logger');
 }
开发者ID:studiocaramia,项目名称:redking_CoreRestBundle,代码行数:7,代码来源:FormattedCommandHelper.php

示例4: execute

 /**
  * Execute the console command
  *
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     $logger = $this->logger;
     Resque_Event::listen('onFailure', function ($exception, $job) use($logger) {
         $logger->error('Error processing job', ['exception' => $exception]);
     });
     if ($input->getOption('shutdown')) {
         $this->shutdownWorkers();
         return;
     }
     $queues = $input->getArgument('queue');
     if (!count($queues)) {
         throw new RuntimeException('Not enough arguments.');
     }
     $count = $input->getOption('count');
     $interval = $input->getOption('interval');
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
         $logLevel = Resque_Worker::LOG_NORMAL;
     } elseif ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
         $logLevel = Resque_Worker::LOG_VERBOSE;
     } else {
         $logLevel = Resque_Worker::LOG_NONE;
     }
     $this->startWorkers($queues, $count, $logLevel, $interval);
 }
开发者ID:bodetree,项目名称:synapse-base,代码行数:33,代码来源:ResqueCommand.php

示例5: handleError

 /**
  * @param array $input
  * @throws \Exception
  */
 protected function handleError(array $input)
 {
     if (OutputInterface::VERBOSITY_VERBOSE <= $this->output->getVerbosity()) {
         $this->output->writeln(print_r($input, true));
     }
     throw new \Exception($input['message']);
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:11,代码来源:StoreCommand.php

示例6: logVerbose

 protected function logVerbose($msg)
 {
     if ($this->output->getVerbosity() < OutputInterface::VERBOSITY_VERBOSE) {
         return;
     }
     $this->output->writeln($msg);
 }
开发者ID:Ravetracer,项目名称:www,代码行数:7,代码来源:CreateTicketsCommand.php

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $confirm = $input->getOption('confirm');
     $perms = \Perms::get();
     if (!$perms->admin_file_galleries) {
         throw new \Exception('Tracker Clear: Admin permission required');
     }
     if ($confirm) {
         if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             $output->writeln('<info>Deleting old filegal files...</info>');
         }
         \TikiLib::lib('filegal')->deleteOldFiles();
         if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             $output->writeln('<info>Deleting old filegal files done</info>');
         }
     } else {
         $query = 'select * from `tiki_files` where `deleteAfter` < ? - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
         $now = time();
         $files = \TikiDb::get()->query($query, array($now));
         if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             if ($files->numrows) {
                 $output->writeln("<comment>Files to delete:</comment>");
                 foreach ($files->result as $file) {
                     $old = ceil(abs($now - $file['lastModif']) / 86400);
                     $days = $old > 1 ? 'days' : 'day';
                     $deleteAfter = \TikiLib::lib('tiki')->get_short_datetime($file['deleteAfter']);
                     $output->writeln("<info>    \"{$file['name']}\" is {$old} {$days} old in gallery #{$file['galleryId']} (id #{$file['fileId']} deleteAfter {$deleteAfter})</info>");
                 }
             } else {
                 $output->writeln("<comment>No files to delete</comment>");
             }
         }
     }
 }
开发者ID:linuxwhy,项目名称:tiki-1,代码行数:34,代码来源:FilesDeleteoldCommand.php

示例8: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /* @var $listener \Hearsay\SuperfeedrBundle\Listening\ListenerInterface */
     $listener = $this->getContainer()->get('hearsay_superfeedr.listener');
     $listener->addNotificationHandler(new NotificationPrinter($output));
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) {
         $output->writeln('');
         $output->writeln('<info>Listening for messages...</info>');
         $output->writeln('');
     }
     try {
         $listener->listen();
     } catch (\Exception $exception) {
         if ($input->getOption('die')) {
             // @codeCoverageIgnoreStart
             die($exception->getMessage() . "\n");
             // @codeCoverageIgnoreEnd
         } else {
             throw $exception;
         }
     }
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) {
         $output->writeln('<info>Finished listening.</info>');
     }
 }
开发者ID:hearsayit,项目名称:HearsaySuperfeedrBundle,代码行数:28,代码来源:ListenCommand.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input);
     $sshUrl = $this->getSelectedEnvironment()->getSshUrl($this->selectApp($input));
     if ($input->getOption('pipe')) {
         $output->write($sshUrl);
         return 0;
     }
     $remoteCommand = $input->getArgument('cmd');
     if (!$remoteCommand && $this->runningViaMulti) {
         throw new \InvalidArgumentException('The cmd argument is required when running via "multi"');
     }
     $sshOptions = 't';
     // Pass through the verbosity options to SSH.
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG) {
         $sshOptions .= 'vv';
     } elseif ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
         $sshOptions .= 'v';
     } elseif ($output->getVerbosity() <= OutputInterface::VERBOSITY_QUIET) {
         $sshOptions .= 'q';
     }
     $command = "ssh -{$sshOptions} " . escapeshellarg($sshUrl);
     if ($remoteCommand) {
         $command .= ' ' . escapeshellarg($remoteCommand);
     }
     return $this->getHelper('shell')->executeSimple($command);
 }
开发者ID:commerceguys,项目名称:platform-cli,代码行数:27,代码来源:EnvironmentSshCommand.php

示例10: runCommand

 /**
  * Run a command through the ProcessBuilder.
  *
  * @param string|array $command
  * @param bool         $allowFailures
  * @param \Closure     $callback           Callback for Process (e.g. for logging output in realtime)
  * @param bool         $cacheMultipleCalls Call multiple calls with this command (to speed-up execution)
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  *
  * @return string
  */
 public function runCommand($command, $allowFailures = false, $callback = null, $cacheMultipleCalls = false)
 {
     if (is_string($command)) {
         $command = $this->parseProcessArguments($command);
     }
     $cacheKey = getcwd() . implode(' ', $command);
     if ($cacheMultipleCalls && isset($this->cache[$cacheKey])) {
         return $this->cache[$cacheKey];
     }
     $builder = new ProcessBuilder($command);
     $builder->setWorkingDirectory(getcwd())->setTimeout(3600);
     $process = $builder->getProcess();
     $remover = function ($untrimmed) {
         return ltrim(rtrim($untrimmed, "'"), "'");
     };
     if ($this->output instanceof OutputInterface) {
         if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
             $commandLine = implode(' ', array_map($remover, explode(' ', $process->getCommandLine())));
             $this->output->writeln('<question>CMD</question> ' . $commandLine);
         }
     }
     $process->run($callback);
     if (!$process->isSuccessful() && !$allowFailures) {
         throw new \RuntimeException($process->getErrorOutput());
     }
     $result = trim($process->getOutput());
     if ($cacheMultipleCalls) {
         $this->cache[$cacheKey] = $result;
     }
     return $result;
 }
开发者ID:mistymagich,项目名称:gush,代码行数:44,代码来源:ProcessHelper.php

示例11: runProcess

 /**
  * @param Process     $process
  * @param bool        $mustRun
  * @param bool        $quiet
  *
  * @return int|string
  * @throws \Exception
  */
 protected function runProcess(Process $process, $mustRun = false, $quiet = true)
 {
     if ($this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
         $this->output->writeln("Running command: <info>" . $process->getCommandLine() . "</info>");
     }
     try {
         $process->mustRun($quiet ? null : function ($type, $buffer) {
             $this->output->write(preg_replace('/^/m', '  ', $buffer));
         });
     } catch (ProcessFailedException $e) {
         if (!$mustRun) {
             return $process->getExitCode();
         }
         // The default for ProcessFailedException is to print the entire
         // STDOUT and STDERR. But if $quiet is disabled, then the user will
         // have already seen the command's output.  So we need to re-throw
         // the exception with a much shorter message.
         $message = "The command failed with the exit code: " . $process->getExitCode();
         $message .= "\n\nFull command: " . $process->getCommandLine();
         if ($quiet) {
             $message .= "\n\nError output:\n" . $process->getErrorOutput();
         }
         throw new \Exception($message);
     }
     $output = $process->getOutput();
     return $output ? rtrim($output) : true;
 }
开发者ID:ecolinet,项目名称:platformsh-cli,代码行数:35,代码来源:ShellHelper.php

示例12: verbose

 public function verbose($log)
 {
     if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
         $log = preg_replace('/^/m', "\t", $log);
         $this->output->writeln($log);
     }
 }
开发者ID:sickhye,项目名称:php-db-migrate,代码行数:7,代码来源:Logger.php

示例13:

 function it_should_not_handle_log_when_verbosity_set_to_quiet(OutputInterface $output)
 {
     $output->getVerbosity()->shouldBeCalled()->willReturn(OutputInterface::VERBOSITY_QUIET);
     $this->isHandling(array('level' => Logger::NOTICE))->shouldReturn(false);
     $output->getVerbosity()->shouldBeCalled()->willReturn(OutputInterface::VERBOSITY_DEBUG);
     $this->isHandling(array('level' => Logger::NOTICE))->shouldReturn(true);
 }
开发者ID:phpguard,项目名称:phpguard,代码行数:7,代码来源:ConsoleHandlerSpec.php

示例14: outputExceptionTrace

 /**
  * @param Throwable $exception
  */
 protected function outputExceptionTrace(Throwable $exception)
 {
     if ($this->output->getVerbosity() >= $this->options['minTraceVerbosity']) {
         $this->output->writeln(sprintf($this->options['traceTemplate'], $exception->getTraceAsString()));
     }
     return $this;
 }
开发者ID:plumphp,项目名称:plum-console,代码行数:10,代码来源:ExceptionFormatter.php

示例15: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Start up application with supplied config...');
     $config = $input->getArgument('applicationConfig');
     $path = stream_resolve_include_path($config);
     if (!is_readable($path)) {
         throw new \InvalidArgumentException("Invalid loader path: {$config}");
     }
     // Init the application once using given config
     // This way the late static binding on the AspectKernel
     // will be on the goaop-zf2-module kernel
     \Zend\Mvc\Application::init(include $path);
     if (!class_exists(AspectKernel::class, false)) {
         $message = "Kernel was not initialized yet. Maybe missing module Go\\ZF2\\GoAopModule in config {$path}";
         throw new \InvalidArgumentException($message);
     }
     $kernel = AspectKernel::getInstance();
     $options = $kernel->getOptions();
     if (empty($options['cacheDir'])) {
         throw new \InvalidArgumentException('Cache warmer require the `cacheDir` options to be configured');
     }
     $enumerator = new Enumerator($options['appDir'], $options['includePaths'], $options['excludePaths']);
     $iterator = $enumerator->enumerate();
     $totalFiles = iterator_count($iterator);
     $output->writeln("Total <info>{$totalFiles}</info> files to process.");
     $iterator->rewind();
     set_error_handler(function ($errno, $errstr, $errfile, $errline) {
         throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
     });
     $index = 0;
     $errors = [];
     foreach ($iterator as $file) {
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
             $output->writeln("Processing file <info>{$file->getRealPath()}</info>");
         }
         $isSuccess = null;
         try {
             // This will trigger creation of cache
             file_get_contents(FilterInjectorTransformer::PHP_FILTER_READ . SourceTransformingLoader::FILTER_IDENTIFIER . '/resource=' . $file->getRealPath());
             $isSuccess = true;
         } catch (\Exception $e) {
             $isSuccess = false;
             $errors[$file->getRealPath()] = $e;
         }
         if ($output->getVerbosity() == OutputInterface::VERBOSITY_NORMAL) {
             $output->write($isSuccess ? '.' : '<error>E</error>');
             if (++$index % 50 == 0) {
                 $output->writeln("({$index}/{$totalFiles})");
             }
         }
     }
     restore_error_handler();
     if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
         foreach ($errors as $file => $error) {
             $message = "File {$file} is not processed correctly due to exception: {$error->getMessage()}";
             $output->writeln($message);
         }
     }
     $output->writeln('<info>Done</info>');
 }
开发者ID:goaop,项目名称:goaop-zf2-module,代码行数:63,代码来源:Zf2WarmupCommand.php


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