php Symfony-Component-Console-Style-SymfonyStyle类(方法)实例源码

下面列出了php Symfony-Component-Console-Style-SymfonyStyle 类(方法)源码代码实例,从而了解它的用法。

作者:edetailla    项目:static-revie   
/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Check Pre-commit requirements');
     $hasError = false;
     $resultOkVal = '<fg=green>✔</>';
     $resultNokVal = '<fg=red>✘</>';
     $commands = ['Composer' => array('command' => 'composer', 'result' => $resultOkVal), 'xmllint' => array('command' => 'xmllint', 'result' => $resultOkVal), 'jsonlint' => array('command' => 'jsonlint', 'result' => $resultOkVal), 'eslint' => array('command' => 'eslint', 'result' => $resultOkVal), 'sass-convert' => array('command' => 'sass-convert', 'result' => $resultOkVal), 'scss-lint' => array('command' => 'scss-lint', 'result' => $resultOkVal), 'phpcpd' => array('command' => 'phpcpd', 'result' => $resultOkVal), 'php-cs-fixer' => array('command' => 'php-cs-fixer', 'result' => $resultOkVal), 'phpmd' => array('command' => 'phpmd', 'result' => $resultOkVal), 'phpcs' => array('command' => 'phpcs', 'result' => $resultOkVal), 'box' => array('command' => 'box', 'result' => $resultOkVal)];
     foreach ($commands as $label => $command) {
         if (!$this->checkCommand($label, $command['command'])) {
             $commands[$label]['result'] = $resultNokVal;
             $hasError = true;
         }
     }
     // Check Php conf param phar.readonly
     if (!ini_get('phar.readonly')) {
         $commands['phar.readonly'] = array('result' => $resultOkVal);
     } else {
         $commands['phar.readonly'] = array('result' => 'not OK (set "phar.readonly = Off" on your php.ini)');
     }
     $headers = ['Command', 'check'];
     $rows = [];
     foreach ($commands as $label => $cmd) {
         $rows[] = [$label, $cmd['result']];
     }
     $io->table($headers, $rows);
     if (!$hasError) {
         $io->success('All Requirements are OK');
     } else {
         $io->note('Please fix all requirements');
     }
     exit(0);
 }

作者:phpb    项目:phpb   
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'));
 }

作者:gnuga    项目:micro-framework-bundl   
/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->comment("Warming up the cache (<info>{$this->cacheDir}</info>)");
     $this->cacheWarmer->warmup($this->cacheDir);
     $io->success('Cache warmed up');
 }

作者:campaignchai    项目:report-google-analytic   
public function execute(SymfonyStyle $io = null)
 {
     $currentProfiles = $this->em->getRepository('CampaignChainLocationGoogleAnalyticsBundle:Profile')->findAll();
     if (empty($currentProfiles)) {
         $io->text('There is no Profile entity to update');
         return true;
     }
     foreach ($currentProfiles as $profile) {
         if (substr($profile->getProfileId(), 0, 2) != 'UA') {
             continue;
         }
         $profile->setPropertyId($profile->getProfileId());
         $gaProfileUrl = $profile->getLocation()->getUrl();
         $google_base_url = 'https:\\/\\/www.google.com\\/analytics\\/web\\/#report\\/visitors-overview\\/a' . $profile->getAccountId() . 'w\\d+p';
         $pattern = '/' . $google_base_url . '(.*)/';
         preg_match($pattern, $gaProfileUrl, $matches);
         if (!empty($matches) && count($matches) == 2) {
             $profile->setProfileId($matches[1]);
             $profile->setIdentifier($profile->getProfileId());
         }
         $this->em->persist($profile);
     }
     $this->em->flush();
     return true;
 }

作者:benj    项目:t   
/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->getFormatter()->setStyle('red', new OutputFormatterStyle('red', 'default'));
     $header = ['Show', 'Episode Title', 'Season/Episode', 'Date', 'Link'];
     $this->displayAsTable($io, $header, $this->getUpcomingEpisodes());
 }

作者:RunOpenCod    项目:exchange-rate-bundl   
/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputStyle = new SymfonyStyle($input, $output);
     $outputStyle->title('Displaying current configuration for currency exchange bundle');
     $this->displaySources($outputStyle)->displayNewLine($outputStyle)->displayProcessors($outputStyle)->displayNewLine($outputStyle)->displayRepository($outputStyle)->displayNewLine($outputStyle)->displayRates($outputStyle)->displayNewLine($outputStyle);
     $outputStyle->success('Configuration is valid.');
 }

作者:edetailla    项目:static-revie   
/**
  * {@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);
     }
 }

作者:jean-pasqualin    项目:i   
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;
     }
 }

作者:enlightened-d    项目:sentry-monito   
/**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Import sentry events');
     $organisation = $input->getArgument('organisation');
     $project = $input->getArgument('project');
     $projectBlacklist = $input->getOption('project-blacklist');
     $sentryRequest = new SentryRequest($input->getOption('sentry-url'), $input->getOption('sentry-api-key'));
     $projects = [$project];
     if (null === $project) {
         $projects = $this->application['project.collector']->getSlugs($sentryRequest, $organisation);
     }
     $progress = new ProgressBar($output);
     $progress->start();
     foreach ($projects as $project) {
         if (in_array($project, $projectBlacklist)) {
             continue;
         }
         $simplifiedEvents = $this->application['event.collector']->getSimplifiedEvents($sentryRequest, $organisation, $project);
         foreach ($simplifiedEvents as $simplifiedEvent) {
             $this->application['importer']->import($organisation, $project, $simplifiedEvent);
             $progress->advance();
         }
     }
     $progress->finish();
     $io->newLine(2);
     $eventCount = $this->application['db']->fetchColumn('SELECT COUNT(*) FROM events');
     $io->success(sprintf('%s events are available.', $eventCount));
 }

作者:php-resqu    项目:resque-bundl   
protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $workerCount = $input->getOption('count');
     $queues = $this->createQueues($input->getArgument('queues'));
     $output->write($queues);
     // This method of worker setup requires an array of queues
     if (!is_array($queues)) {
         throw new \Exception("Queues not initialized correctly");
     }
     $workers = array();
     for ($i = 0; $i < $workerCount; ++$i) {
         $worker = $this->workerFactory->createWorker();
         $workerProcess = $this->workerFactory->createWorkerProcess($worker);
         foreach ($queues as $queue) {
             $worker->addQueue($queue);
         }
         $workers[] = $workerProcess;
     }
     $this->foreman->pruneDeadWorkers();
     $this->foreman->work($workers, $input->getOption('wait'));
     echo sprintf('%d workers attached to the %s queues successfully started.', count($workers), implode($queues, ','));
     //        echo sprintf(
     //            'Workers (%s)',
     //            implode(', ', $workers)
     //        );
 }

作者:Kyra277    项目:AM   
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);
 }

作者:phpb    项目:phpb   
/**
  * Executes the command reparser:list
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return integer
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->section($this->user->lang('CLI_DESCRIPTION_REPARSER_AVAILABLE'));
     $io->listing($this->reparser_names);
     return 0;
 }

作者:Kyra277    项目:AM   
/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->caution('The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.');
     }
     $name = $input->getArgument('name');
     if (empty($name)) {
         $output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $output->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $output->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $output->title(sprintf('Current configuration for "%s"', $name));
     }
     $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }

作者:Ener-Getic    项目:symfon   
/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $router = $this->getContainer()->get('router');
     $context = $router->getContext();
     if (null !== ($method = $input->getOption('method'))) {
         $context->setMethod($method);
     }
     if (null !== ($scheme = $input->getOption('scheme'))) {
         $context->setScheme($scheme);
     }
     if (null !== ($host = $input->getOption('host'))) {
         $context->setHost($host);
     }
     $matcher = new TraceableUrlMatcher($router->getRouteCollection(), $context);
     $traces = $matcher->getTraces($input->getArgument('path_info'));
     $io->newLine();
     $matches = false;
     foreach ($traces as $trace) {
         if (TraceableUrlMatcher::ROUTE_ALMOST_MATCHES == $trace['level']) {
             $io->text(sprintf('Route <info>"%s"</> almost matches but %s', $trace['name'], lcfirst($trace['log'])));
         } elseif (TraceableUrlMatcher::ROUTE_MATCHES == $trace['level']) {
             $io->success(sprintf('Route "%s" matches', $trace['name']));
             $routerDebugCommand = $this->getApplication()->find('debug:router');
             $routerDebugCommand->run(new ArrayInput(array('name' => $trace['name'])), $output);
             $matches = true;
         } elseif ($input->getOption('verbose')) {
             $io->text(sprintf('Route "%s" does not match: %s', $trace['name'], $trace['log']));
         }
     }
     if (!$matches) {
         $io->error(sprintf('None of the routes match the path "%s"', $input->getArgument('path_info')));
         return 1;
     }
 }

作者:ayoa    项目:symfon   
/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $pools = array();
     $clearers = array();
     $container = $this->getContainer();
     $cacheDir = $container->getParameter('kernel.cache_dir');
     foreach ($input->getArgument('pools') as $id) {
         $pool = $container->get($id);
         if ($pool instanceof CacheItemPoolInterface) {
             $pools[$id] = $pool;
         } elseif ($pool instanceof Psr6CacheClearer) {
             $clearers[$id] = $pool;
         } else {
             throw new \InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
         }
     }
     foreach ($clearers as $id => $clearer) {
         $io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
         $clearer->clear($cacheDir);
     }
     foreach ($pools as $id => $pool) {
         $io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
         $pool->clear();
     }
     $io->success('Cache was successfully cleared.');
 }

作者:SURFne    项目:grouphu   
/**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $lockHandler = new LockHandler('app:sync.lock');
     if (!$lockHandler->lock()) {
         $io->warning('Sync process already running');
         return;
     }
     $service = $this->getContainer()->get('app.sync');
     switch ($input->getOption('type')) {
         case 'users':
             $service->syncUsers();
             break;
         case 'groups':
             $service->syncGroups();
             break;
         case 'grouphub':
             $service->syncGrouphubGroups();
             break;
         case 'queue':
             $service->syncGrouphubGroupsFromQueue();
             break;
         default:
             $service->sync();
     }
     $io->success('Done!');
 }

作者:octav    项目:cm   
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();
         }
     }
 }

作者:LinkValu    项目:MajoraInstalle   
/**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $io = new SymfonyStyle($input, $output);
        $commandTitle = '                     Majora Installer                    ';
        $commandHelper = <<<COMMAND_HELPER
    <info>This is installer for majora-standard-edition</info>
   
    Create project to <info>current directory</info>: 
    
        <comment>majora new <Project Name></comment>
        
    Create project <info>for path</info>: 
    
        <comment>majora new <Path></comment>
        
    Create project <info>based on a specific branch</info>: 
    
        <comment>majora new <Project Name> <BranchName> </comment>
        
        
        
COMMAND_HELPER;
        $io->title($commandTitle);
        $io->writeln($commandHelper);
    }

作者:kodazz    项目:framewor   
protected function execute(InputInterface $input, OutputInterface $output)
 {
     $namespace = $input->getArgument('namespace');
     /** @var RouteCollection $RouteCollection */
     $RouteCollection = Service::get('kernel.routes');
     $Routes = $RouteCollection->all();
     $io = new SymfonyStyle($input, $output);
     $io->newLine();
     $rows = array();
     /** @var Route $Route */
     foreach ($Routes as $name => $Route) {
         $path = $Route->getPath();
         $local = $Route->getOption('_locale');
         $controller = $Route->getDefault('controller');
         $host = $Route->getHost();
         $methods = implode(', ', $Route->getMethods());
         $schemes = implode(', ', $Route->getSchemes());
         $_requirements = $Route->getRequirements();
         $requirements = null;
         $name = $local ? str_replace("-{$local}", '', $name) : $name;
         foreach ($_requirements as $var => $patt) {
             $requirements .= "\"{$var}={$patt}\" ";
         }
         $requirements = $requirements ? rtrim($requirements, ',') : '';
         $rows[] = array($name, $path, $local, $methods, $schemes);
     }
     $io->table(array('Name', 'Path', 'Local', 'Method', 'Scheme'), $rows);
     $io->success('Se han mostrado las rutas del proyecto exitosamente.');
 }

作者:gnuga    项目:micro-framework-bundl   
/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->comment("Clearing the cache (<info>{$this->cacheDir}</info>)");
     $this->cacheClearer->clear($this->cacheDir);
     $io->success('Cache cleared');
 }


问题


面经


文章

微信
公众号

扫码关注公众号