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


PHP SymfonyStyle::error方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = str_replace('/', '\\', $input->getArgument('name'));
     $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
     $this->cache->purge();
     if (!in_array($name, $this->load_migrations())) {
         $io->error($this->language->lang('MIGRATION_NOT_VALID', $name));
         return 1;
     } else {
         if ($this->migrator->migration_state($name) === false) {
             $io->error($this->language->lang('MIGRATION_NOT_INSTALLED', $name));
             return 1;
         }
     }
     try {
         while ($this->migrator->migration_state($name) !== false) {
             $this->migrator->revert($name);
         }
     } catch (\phpbb\db\migration\exception $e) {
         $io->error($e->getLocalisedMessage($this->user));
         $this->finalise_update();
         return 1;
     }
     $this->finalise_update();
     $io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
 }
开发者ID:phpbb,项目名称:phpbb,代码行数:27,代码来源:revert.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     mb_internal_encoding('UTF-8');
     try {
         list($line, $colonne) = explode("x", $input->getOption("size"));
         $symfonyStyle = new SymfonyStyle($input, $output);
         $symfonyStyle->title("IA");
         $mapRender = !$input->getOption("curse") ? new ConsoleMapRender($output, true) : new NCurseRender($line, $colonne);
         if (!$input->getOption("load-dump")) {
             $sizeMap = $mapRender->getSize();
             $mapProvider = $input->getOption("map") ? new FileMapProvider($input->getOption("map")) : new RandomMapProvider($sizeMap["y"], $sizeMap["x"]);
             $map = new MapBuilder($mapProvider->getMap());
             $world = new World($map, array($this->addChat(5, 5), $this->addChat(10, 10)));
         } else {
             $file = $input->getOption("load-dump");
             if (!file_exists($file)) {
                 if (extension_loaded("ncurses") && $mapRender instanceof NCurseRender) {
                     ncurses_end();
                 }
                 $symfonyStyle->error("le fichier {$file} n'existe pas");
                 return;
             }
             $world = unserialize(file_get_contents($file))->getFlashMemory()->all()[0]->getData();
         }
         while (1) {
             $this->render($mapRender, $world);
         }
     } catch (\Exception $e) {
         if (extension_loaded("ncurses") && $mapRender instanceof NCurseRender) {
             ncurses_end();
         }
         $symfonyStyle->error($e->getMessage());
         return;
     }
 }
开发者ID:jean-pasqualini,项目名称:ia,代码行数:35,代码来源:ApplicationCommand.php

示例3: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Pre-commit delete');
     $git = new GitVersionControl();
     $projectBase = $git->getProjectBase();
     $hookDir = $projectBase . '/.git/hooks';
     if (!$io->confirm('Are you sure to remove Pre-commit hooks on this project?', true)) {
         exit(0);
     }
     $output->writeln('');
     if (!is_dir($hookDir)) {
         $io->error(sprintf('The git hook directory does not exist (%s)', $hookDir));
         exit(1);
     }
     $target = $hookDir . '/pre-commit';
     $fs = new Filesystem();
     if (is_file($target)) {
         $fs->remove($target);
         $io->success('pre-commit was deleted');
         exit(0);
     }
     $io->error(sprintf('pre-commit file does\'nt exist (%s)', $target));
     exit(1);
 }
开发者ID:edetaillac,项目名称:static-review,代码行数:28,代码来源:HookDeleteCommand.php

示例4: error

 protected function error($message)
 {
     if ($this->verbose) {
         $this->io->error($message);
     } else {
         $this->output->writeln('[ERROR]' . $message);
     }
     die;
 }
开发者ID:carloboy7,项目名称:ownsongmovie,代码行数:9,代码来源:AbstractCommand.php

示例5: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = new SymfonyStyle($input, $output);
     $this->environment = new Environment(getcwd(), new Git());
     if (!$this->environment->isInRepository()) {
         $this->output->error('Versioner needs to run in a folder with Git');
         return 1;
     }
     $this->fire();
 }
开发者ID:Anahkiasen,项目名称:versioner,代码行数:14,代码来源:AbstractCommand.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io = new SymfonyStyle($input, $output);
     $this->sort = $input->getOption('sort');
     $this->sleepTime = $input->getOption('sleepTime');
     if (!$input->hasOption('sleepTime') && $output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) {
         $this->sleepTime = 25;
     }
     // Transform milliseconds in microseconds for usleep()
     $this->sleepTime = $this->sleepTime * 1000;
     $this->numberOfCodesToGenerate = $input->getOption('amount');
     // The length of each outputted code
     $this->codeLength = $input->getOption('length');
     // All possible chars. By default, 'A' to 'Z' and '0' to '9'
     $this->possibleChars = str_split($input->getOption('characters'));
     $baseNumberOfChars = count($this->possibleChars);
     $this->possibleChars = array_unique($this->possibleChars);
     // If there's an error here, we'll say it later
     $maxPossibleNumberOfCombinations = pow(count($this->possibleChars), $this->codeLength);
     if ($maxPossibleNumberOfCombinations < $this->numberOfCodesToGenerate) {
         $this->io->error(sprintf('Cannot generate %s combinations because there are only %s combinations possible', number_format($this->numberOfCodesToGenerate, 0, '', ' '), number_format($maxPossibleNumberOfCombinations, 0, '', ' ')));
         return 1;
     } else {
         $this->io->block(sprintf('Generating %s combinations.', number_format($this->numberOfCodesToGenerate, 0, '', ' ')), null, 'info');
         if ($maxPossibleNumberOfCombinations > $this->numberOfCodesToGenerate) {
             $this->io->block(sprintf('Note: If you need you can generate %s more combinations (with a maximum of %s).', number_format($maxPossibleNumberOfCombinations - $this->numberOfCodesToGenerate, 0, '', ' '), number_format($maxPossibleNumberOfCombinations, 0, '', ' ')), null, 'comment');
         }
     }
     $this->io->block('Available characters:');
     $this->io->block(implode('', $this->possibleChars), null, 'info');
     $codesList = $this->doGenerate();
     $outputFile = $input->getOption('output');
     if ($outputFile) {
         $save = true;
         if (file_exists($outputFile)) {
             $save = $this->io->confirm(sprintf('File %s exists. Erase it?', $outputFile), false);
         }
         if ($save) {
             $this->io->block(sprintf('Output results to %s', $outputFile), null, 'info');
             if (!file_put_contents($outputFile, implode("\n", $codesList))) {
                 throw new \Exception(sprintf('Could not write to %s...', $outputFile));
             }
         }
     } else {
         $this->io->text($codesList);
     }
     if ($baseNumberOfChars !== count($this->possibleChars)) {
         $this->io->warning(sprintf('We detected that there were duplicate characters in "%s", so we removed them.', $input->getOption('characters')));
     }
     return 0;
 }
开发者ID:Orbitale,项目名称:RandomStringGenerator,代码行数:51,代码来源:GenerateCommand.php

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // throw new \Exception('boo');
     $directory = realpath($input->getArgument('directory'));
     $directoryOutput = $input->getArgument('outputdirectory');
     /* @var $logger Psr\Log\LoggerInterface */
     $this->logger = $this->getContainer()->get('logger');
     $io = new SymfonyStyle($input, $output);
     $io->title('DDD Model Generation');
     $clean = $input->hasOption('clean');
     if ($clean) {
         $io->section('Clean output directoty');
         $fs = new \Symfony\Component\Filesystem\Filesystem();
         try {
             $fs->remove($directoryOutput);
         } catch (IOExceptionInterface $e) {
             $io->error($e->getMessage());
         }
         $io->text('clean of ' . $directoryOutput . ' completed');
     }
     if (is_dir($directory)) {
         $finder = new Finder();
         $finder->search($directory);
         foreach ($finder->getFindedFiles() as $file) {
             if (pathinfo($file, PATHINFO_FILENAME) == 'model.yml') {
                 $io->text('Analizzo model.yml in ' . pathinfo($file, PATHINFO_DIRNAME));
                 $dddGenerator = new DDDGenerator();
                 $dddGenerator->setLogger($this->logger);
                 $dddGenerator->analyze($file);
                 $dddGenerator->generate($directoryOutput);
             }
         }
         $io->section('Php-Cs-Fixer on generated files');
         $fixer = new \Symfony\CS\Console\Command\FixCommand();
         $input = new ArrayInput(['path' => $directoryOutput, '--level' => 'psr2', '--fixers' => 'eof_ending,strict_param,short_array_syntax,trailing_spaces,indentation,line_after_namespace,php_closing_tag']);
         $output = new BufferedOutput();
         $fixer->run($input, $output);
         $content = $output->fetch();
         $io->text($content);
         if (count($this->errors) == 0) {
             $io->success('Completed generation');
         } else {
             $io->error($this->errors);
         }
     } else {
         $io->caution('Directory ' . $directory . ' not valid');
     }
     // PER I WARNING RECUPERABILI
     //$io->note('Generate Class');
 }
开发者ID:yoghi,项目名称:madda,代码行数:50,代码来源:GenerateModelCommand.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->migrationPath = str_replace('/', DIRECTORY_SEPARATOR, $this->getContainer()->getParameter('campaignchain_update.bundle.schema_dir'));
     $io = new SymfonyStyle($input, $output);
     $io->title('Gathering migration files from CampaignChain packages');
     $io->newLine();
     $locator = $this->getContainer()->get('campaignchain.core.module.locator');
     $bundleList = $locator->getAvailableBundles();
     if (empty($bundleList)) {
         $io->error('No CampaignChain Module found');
         return;
     }
     $migrationsDir = $this->getContainer()->getParameter('doctrine_migrations.dir_name');
     $fs = new Filesystem();
     $table = [];
     foreach ($bundleList as $bundle) {
         $packageSchemaDir = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $bundle->getName() . $this->migrationPath;
         if (!$fs->exists($packageSchemaDir)) {
             continue;
         }
         $migrationFiles = new Finder();
         $migrationFiles->files()->in($packageSchemaDir)->name('Version*.php');
         $files = [];
         /** @var SplFileInfo $migrationFile */
         foreach ($migrationFiles as $migrationFile) {
             $fs->copy($migrationFile->getPathname(), $migrationsDir . DIRECTORY_SEPARATOR . $migrationFile->getFilename(), true);
             $files[] = $migrationFile->getFilename();
         }
         $table[] = [$bundle->getName(), implode(', ', $files)];
     }
     $io->table(['Module', 'Versions'], $table);
     if (!$input->getOption('gather-only')) {
         $this->getApplication()->run(new ArrayInput(['command' => 'doctrine:migrations:migrate', '--no-interaction' => true]), $output);
     }
 }
开发者ID:campaignchain,项目名称:update,代码行数:35,代码来源:UpdateSchemaCommand.php

示例9: execute

 /**
  * Executes the command.
  *
  * Checks if an update is available.
  * If at least one is available, a message is printed and if verbose mode is set the list of possible updates is printed.
  * If their is none, nothing is printed unless verbose mode is set.
  *
  * @param InputInterface $input Input stream, used to get the options.
  * @param OutputInterface $output Output stream, used to print messages.
  * @return int 0 if the board is up to date, 1 if it is not and 2 if an error occured.
  * @throws \RuntimeException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $recheck = true;
     if ($input->getOption('cache')) {
         $recheck = false;
     }
     $stability = null;
     if ($input->getOption('stability')) {
         $stability = $input->getOption('stability');
         if (!($stability == 'stable') && !($stability == 'unstable')) {
             $io->error($this->language->lang('CLI_ERROR_INVALID_STABILITY', $stability));
             return 3;
         }
     }
     $ext_name = $input->getArgument('ext-name');
     if ($ext_name != null) {
         if ($ext_name == 'all') {
             return $this->check_all_ext($io, $stability, $recheck);
         } else {
             return $this->check_ext($input, $io, $stability, $recheck, $ext_name);
         }
     } else {
         return $this->check_core($input, $io, $stability, $recheck);
     }
 }
开发者ID:phpbb,项目名称:phpbb,代码行数:38,代码来源:check.php

示例10: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $model = $input->getArgument('model');
     $seeds = $input->getArgument('seeds');
     $io = new SymfonyStyle($input, $output);
     if (!class_exists($model)) {
         $io->error(array('The model you specified does not exist.', 'You can create a model with the "model:create" command.'));
         return 1;
     }
     $this->dm = $this->createDocumentManager($input->getOption('server'));
     $faker = Faker\Factory::create();
     AnnotationRegistry::registerAutoloadNamespace('Hive\\Annotations', dirname(__FILE__) . '/../../');
     $reflectionClass = new \ReflectionClass($model);
     $properties = $reflectionClass->getProperties(\ReflectionProperty::IS_PUBLIC);
     $reader = new AnnotationReader();
     for ($i = 0; $i < $seeds; $i++) {
         $instance = new $model();
         foreach ($properties as $property) {
             $name = $property->getName();
             $seed = $reader->getPropertyAnnotation($property, 'Hive\\Annotations\\Seed');
             if ($seed !== null) {
                 $fake = $seed->fake;
                 if (class_exists($fake)) {
                     $instance->{$name} = $this->createFakeReference($fake);
                 } else {
                     $instance->{$name} = $faker->{$seed->fake};
                 }
             }
         }
         $this->dm->persist($instance);
     }
     $this->dm->flush();
     $io->success(array("Created {$seeds} seeds for {$model}"));
 }
开发者ID:100hz,项目名称:hive-console,代码行数:37,代码来源:ModelSeedCommand.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $fileInput = trim($input->getArgument('file'));
     $pathInfoFile = pathinfo(realpath($fileInput));
     $file = new File('', realpath($fileInput), $pathInfoFile['dirname']);
     $fileCollection = new FileCollection();
     $fileCollection = $fileCollection->append($file);
     $reporter = new Reporter($output, 1);
     $review = new StaticReview($reporter);
     $review->addReview(new PhpCsFixerReview(self::AUTO_ADD_GIT));
     // Review the staged files.
     $review->files($fileCollection);
     // Check if any matching issues were found.
     if ($reporter->hasIssues()) {
         $reporter->displayReport();
     }
     if ($reporter->hasIssueLevel(Issue::LEVEL_ERROR)) {
         $io->error('✘ Please fix the errors above.');
         exit(1);
     } else {
         $io->success('✔ Looking good.');
         exit(0);
     }
 }
开发者ID:edetaillac,项目名称:static-review,代码行数:28,代码来源:PhpCsFixerCommand.php

示例12: updateChangelog

 /**
  * @return Changelog
  */
 protected function updateChangelog()
 {
     // If the release already exists and we don't want to overwrite it, cancel
     $question = 'Version <comment>' . $this->version . '</comment> already exists, create anyway?';
     if ($this->changelog->hasRelease($this->version) && !$this->output->confirm($question, false)) {
         return false;
     }
     // Summarize commits
     $this->summarizeCommits();
     // Gather changes for new version
     $this->output->section('Gathering changes for <comment>' . $this->version . '</comment>');
     $changes = $this->gatherChanges();
     if (!$changes) {
         $this->output->error('No changes to create version with');
         return false;
     }
     if ($this->from) {
         $from = $this->changelog->getRelease($this->from);
         $this->changelog->removeRelease($this->from);
         $changes = array_merge_recursive($from['changes'], $changes);
     }
     // Add to changelog
     $this->changelog->addRelease(['name' => $this->version, 'date' => date('Y-m-d'), 'changes' => $changes]);
     // Show to user and confirm
     $preview = $this->changelog->toMarkdown();
     $this->output->note($preview);
     if (!$this->output->confirm('This is your new CHANGELOG.md, all good?')) {
         return false;
     }
     // Write out to CHANGELOG.md
     $this->changelog->save();
     return $this->changelog;
 }
开发者ID:Anahkiasen,项目名称:versioner,代码行数:36,代码来源:Versioner.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $stdout = $output;
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':l')) {
         $output->caution('The use of "twig:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:twig" instead.');
     }
     $twig = $this->getTwigEnvironment();
     if (null === $twig) {
         $output->error('The Twig environment needs to be set.');
         return 1;
     }
     $filenames = $input->getArgument('filename');
     if (0 === count($filenames)) {
         if (0 !== ftell(STDIN)) {
             throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.');
         }
         $template = '';
         while (!feof(STDIN)) {
             $template .= fread(STDIN, 1024);
         }
         return $this->display($input, $stdout, $output, array($this->validate($twig, $template, uniqid('sf_'))));
     }
     $filesInfo = $this->getFilesInfo($twig, $filenames);
     return $this->display($input, $stdout, $output, $filesInfo);
 }
开发者ID:Kyra2778,项目名称:AMR,代码行数:26,代码来源:LintCommand.php

示例14: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
     $groupRepository = $entityManager->getRepository('OctavaAdministratorBundle:Group');
     $resourceRepository = $entityManager->getRepository('OctavaAdministratorBundle:Resource');
     $groupNames = $input->getOption('group');
     foreach ($groupNames as $groupName) {
         /** @var Group $group */
         $group = $groupRepository->findOneBy(['name' => $groupName]);
         if (!$group) {
             $io->error(sprintf('Group "%s" not found', $groupName));
             continue;
         }
         $rows = [];
         $existsResources = $group->getResources();
         /** @var \Octava\Bundle\AdministratorBundle\Entity\Resource $resource */
         foreach ($resourceRepository->findAll() as $resource) {
             if ($existsResources->contains($resource)) {
                 continue;
             }
             $group->addResource($resource);
             $rows[] = [$resource->getResource(), $resource->getAction()];
         }
         if ($rows) {
             $io->section($groupName);
             $headers = ['Resource', 'Action'];
             $io->table($headers, $rows);
             $entityManager->persist($group);
             $entityManager->flush();
         }
     }
 }
开发者ID:octava,项目名称:cms,代码行数:33,代码来源:GrantAllForGroupCommand.php

示例15: 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


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