當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormatterHelper::formatBlock方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Helper\FormatterHelper::formatBlock方法的典型用法代碼示例。如果您正苦於以下問題:PHP FormatterHelper::formatBlock方法的具體用法?PHP FormatterHelper::formatBlock怎麽用?PHP FormatterHelper::formatBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Helper\FormatterHelper的用法示例。


在下文中一共展示了FormatterHelper::formatBlock方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testFormatBlock

 public function testFormatBlock()
 {
     $formatter = new FormatterHelper();
     $this->assertEquals('<error> Some text to display </error>', $formatter->formatBlock('Some text to display', 'error'), '::formatBlock() formats a message in a block');
     $this->assertEquals("<error> Some text to display </error>\n<error> foo bar              </error>", $formatter->formatBlock(array('Some text to display', 'foo bar'), 'error'), '::formatBlock() formats a message in a block');
     $this->assertEquals("<error>                        </error>\n<error>  Some text to display  </error>\n<error>                        </error>", $formatter->formatBlock('Some text to display', 'error', true), '::formatBlock() formats a message in a block');
 }
開發者ID:notbrain,項目名稱:symfony,代碼行數:7,代碼來源:FormatterHelperTest.php

示例2: executeWithStack

 protected function executeWithStack(Stack $stack, InputInterface $input, OutputInterface $output)
 {
     $blueprint = $this->blueprintFactory->getBlueprintByStack($stack);
     $diff = new Diff($output);
     $diff->setStack($stack)->setBlueprint($blueprint);
     $formatter = new FormatterHelper();
     $output->writeln("\n" . $formatter->formatBlock(['Parameters:'], 'error', true) . "\n");
     $diff->diffParameters();
     $output->writeln("\n" . $formatter->formatBlock(['Template:'], 'error', true) . "\n");
     $diff->diffTemplates();
 }
開發者ID:aoepeople,項目名稱:stackformation,代碼行數:11,代碼來源:DiffCommand.php

示例3: run

 /**
  * Run the dotenv diff
  */
 public static function run()
 {
     $output = new ConsoleOutput();
     $formatter = new FormatterHelper();
     $env = self::readFile('.env');
     $envExample = self::readFile('.env.example');
     // Check which variables are missing and which ones are extra
     $envKeys = array_keys($env);
     $envExampleKeys = array_keys($envExample);
     $missing = array_diff($envExampleKeys, $envKeys);
     $extra = array_diff($envKeys, $envExampleKeys);
     if (count($missing) > 0 || count($extra) > 0) {
         $output->writeln('');
         $warning = $formatter->formatBlock('Warning: Your .env and .env.example files are not in sync.', 'bg=blue;fg=white', true);
         $output->writeln($warning);
     }
     if (count($missing) > 0) {
         $output->writeln("\n<comment>The following variables are missing from your .env file:<comment>");
         foreach ($missing as $variable) {
             $output->writeln(sprintf('<info>%s=%s<info>', $variable, $envExample[$variable]));
         }
     }
     if (count($extra) > 0) {
         $output->writeln("\n<comment>The following variables are in your .env file but not in .env.example:<comment>");
         foreach ($extra as $variable) {
             $output->writeln(sprintf('<info>%s=%s<info>', $variable, $env[$variable]));
         }
     }
     $output->writeln('');
 }
開發者ID:kielabokkie,項目名稱:dotenv-diff,代碼行數:33,代碼來源:DotenvDiff.php

示例4: notify

 public function notify(\Exception $exception)
 {
     if (!$exception instanceof ServiceNotFoundException) {
         return;
     }
     $serviceId = $exception->getId();
     $guessedFqcn = $this->guessFqcn($serviceId);
     $definition = new Definition();
     $definition->setClass($guessedFqcn);
     $containerBuilder = new ContainerBuilder();
     $containerBuilder->addDefinitions([$serviceId => $definition]);
     $dumper = new YamlDumper($containerBuilder);
     $result = $dumper->dump();
     $message = sprintf('Service `%s` missing. Define it in your services.yml:', $serviceId);
     $this->output->writeln('--- ' . $message . PHP_EOL);
     $this->output->write($result, true);
     $errorMessages = ['Service ' . $serviceId . ' was not found.'];
     $formatter = new FormatterHelper();
     $formattedBlock = $formatter->formatBlock($errorMessages, 'error', true);
     $this->output->writeln('');
     $this->output->writeln($formattedBlock);
     $this->output->writeln('');
     $question = sprintf('<question>Do you want to create a specification for %s? (Y/n)</question>', $guessedFqcn);
     $dialog = new DialogHelper();
     if ($dialog->askConfirmation($this->output, $question, true)) {
         $this->specRunner->runDescCommand($guessedFqcn);
     }
 }
開發者ID:kix,項目名稱:behat-sf2-service-generator,代碼行數:28,代碼來源:NonExistentServiceObserver.php

示例5: printErrorBlock

 /**
  * Print a debugging message out in a big red block
  *
  * @param $string
  */
 protected function printErrorBlock($string)
 {
     if ($this->formatterHelper === null) {
         $this->formatterHelper = new FormatterHelper();
     }
     $output = $this->formatterHelper->formatBlock($string, 'bg=red;fg=white', true);
     $this->printDebug($output);
 }
開發者ID:zcichanski,項目名稱:symfony2-rest,代碼行數:13,代碼來源:ApiTestCase.php

示例6: testFormatBlockWithDiacriticLetters

 public function testFormatBlockWithDiacriticLetters()
 {
     if (!extension_loaded('mbstring')) {
         $this->markTestSkipped('This test requires mbstring to work.');
     }
     $formatter = new FormatterHelper();
     $this->assertEquals('<error>                       </error>' . "\n" . '<error>  Du texte à afficher  </error>' . "\n" . '<error>                       </error>', $formatter->formatBlock('Du texte à afficher', 'error', true), '::formatBlock() formats a message in a block');
 }
開發者ID:laiello,項目名稱:masfletes,代碼行數:8,代碼來源:FormatterHelperTest.php

示例7: executeWithBlueprint

 protected function executeWithBlueprint(Blueprint $blueprint, InputInterface $input, OutputInterface $output)
 {
     $blueprintAction = new BlueprintAction($blueprint, $this->profileManager, $output);
     $blueprintAction->validateTemplate();
     // will throw an exception if there's a problem
     $formatter = new FormatterHelper();
     $formattedBlock = $formatter->formatBlock(['No validation errors found.'], 'info', true);
     $output->writeln("\n\n{$formattedBlock}\n\n");
 }
開發者ID:aoepeople,項目名稱:stackformation,代碼行數:9,代碼來源:ValidateCommand.php

示例8: setUp

 /**
  * Sets up suite for a test.
  *
  * @param Environment $env
  * @param SpecificationIterator $iterator
  * @param Boolean $skip
  *
  * @return Setup
  */
 public function setUp(Environment $env, SpecificationIterator $iterator, $skip)
 {
     spl_autoload_register(function ($class) {
         $errorMessages = [$class . ' was not found.'];
         $formatter = new FormatterHelper();
         $formattedBlock = $formatter->formatBlock($errorMessages, 'error', true);
         $this->output->writeln('');
         $this->output->writeln($formattedBlock);
         $this->output->writeln('');
         $question = sprintf('Do you want to create a specification for %s? (Y/n)', $class);
         $questionBlock = $formatter->formatBlock($question, 'question', true);
         $dialog = new DialogHelper();
         if ($dialog->askConfirmation($this->output, $questionBlock, true)) {
             $this->output->writeln('');
             $this->specRunner->runDescCommand($class);
         }
     }, true, false);
     return $this->baseTester->setUp($env, $iterator, $skip);
 }
開發者ID:vukanac,項目名稱:PhpSpecExtension,代碼行數:28,代碼來源:PhpSpecTester.php

示例9: format

 public static function format(ConstraintViolationList $problems, GeneratorInterface $generator, FormatterHelper $formatter)
 {
     $messages = [];
     // add header message
     $problemCount = count($problems);
     $name = $generator->getName();
     $messages[] = "While trying to call the generator '{$name}', {$problemCount} problems were found:";
     $messages[] = "";
     /** @var ConstraintViolation $problem */
     foreach ($problems as $problem) {
         $messages[] = "In \$arguments{$problem->getPropertyPath()}: {$problem->getMessage()}";
     }
     return $formatter->formatBlock($messages, 'error', true);
 }
開發者ID:tweedegolf,項目名稱:generator,代碼行數:14,代碼來源:ValidationProblemFormatter.php

示例10: run

 /**
  * Run the dependency analysis.
  *
  * @return void
  */
 public function run()
 {
     $this->setUp();
     $this->progress->start();
     try {
         $this->search();
         $this->progress->finish();
     } catch (\Exception $e) {
         $this->progress->finish();
         $this->application->renderException($e, $this->output);
         if ($this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
             $this->formatter->formatBlock($this->io->getOutput(), 'error');
         }
     }
 }
開發者ID:bit3,項目名稱:composer-global-depends,代碼行數:20,代碼來源:DependencyAnalyser.php

示例11: renderErrors

 public function renderErrors(Suite $suite)
 {
     $this->renderSuite($suite);
     if (true === $suite->isSuccessful()) {
         return;
     }
     $formatter = new FormatterHelper();
     foreach ($suite->getTests() as $test) {
         if (true === $test->isSuccessful()) {
             continue;
         }
         $this->output->writeln('');
         $lines = [$test];
         if (false === empty($test->getErrorOutput())) {
             $lines[] = '';
             $lines[] = $test->getErrorOutput();
         }
         $this->output->writeln($formatter->formatBlock($lines, 'error', true));
     }
 }
開發者ID:PedroTroller,項目名稱:CircleCI-Parallel-Builder,代碼行數:20,代碼來源:SuiteHelper.php

示例12: changeUser

 /**
  * @return bool
  */
 private function changeUser()
 {
     $user = $this->container->getConfig()->get('command.user');
     // Bypass cache commands as we need the sudoer user to run the commands
     if (null !== $user && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'flushall') && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'redis:flushall') && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'apc:flushall')) {
         $name = $user;
         $user = posix_getpwnam($user);
         posix_setgid($user['gid']);
         posix_setuid($user['uid']);
         if (posix_geteuid() !== (int) $user['uid']) {
             $output = new ConsoleOutput();
             $formatter = new FormatterHelper();
             $output->writeln('', true);
             $errorMessages = array('', ' [Error] ', ' Could not change user to ' . $name . ' ', '');
             $formattedBlock = $formatter->formatBlock($errorMessages, 'error');
             $output->writeln($formattedBlock);
             $output->writeln('', true);
             return false;
         }
     }
     return true;
 }
開發者ID:sinergi,項目名稱:core,代碼行數:25,代碼來源:CommandRuntime.php

示例13: doRun

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $output->writeln(self::$logo);
     if (0 === count($this->files)) {
         $output->writeln('<info>No files given to check.</info>');
         return 0;
     }
     /* @var $command \Symfony\Component\Console\Command\Command */
     foreach ($this->getDefaultCommands() as $command) {
         if (false === $this->configuration[$command->getName()]['enabled']) {
             continue;
         }
         try {
             $command->run($input, $output);
         } catch (\Exception $e) {
             $formattedBlock = $this->formatter->formatBlock($e->getMessage(), 'error');
             $output->writeln($formattedBlock);
             return 1;
         }
     }
     $output->writeln('<info>Well done!</info>');
     return 0;
 }
開發者ID:Techbot,項目名稱:php-hooks,代碼行數:29,代碼來源:Application.php

示例14: outputBlock

 private function outputBlock($message, $success = true)
 {
     $color = $success ? 'green' : 'red';
     $message = ($success ? '[OK]' : '[ERROR]') . ' ' . $message;
     $this->output->writeln($this->formatterHelper->formatBlock($message, 'bg=' . $color, true));
 }
開發者ID:wouterj,項目名稱:docbot,代碼行數:6,代碼來源:Console.php

示例15: testFormatBlockLGEscaping

 public function testFormatBlockLGEscaping()
 {
     $formatter = new FormatterHelper();
     $this->assertEquals('<error>                            </error>' . "\n" . '<error>  \\<info>some info\\</info>  </error>' . "\n" . '<error>                            </error>', $formatter->formatBlock('<info>some info</info>', 'error', true), '::formatBlock() escapes \'<\' chars');
 }
開發者ID:JesseDarellMoore,項目名稱:CS499,代碼行數:5,代碼來源:FormatterHelperTest.php


注:本文中的Symfony\Component\Console\Helper\FormatterHelper::formatBlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。