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


PHP fixer::setStopwatch方法代碼示例

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


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

示例1: execute

 /**
  * Execute the command line :
  * php app/console swagger:generate --file=Resources/example/swagger.json.
  *
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $style = new OutputFormatterStyle('red', 'yellow', array('bold', 'blink'));
     $output->getFormatter()->setStyle('fire', $style);
     $verbosity = $output->getVerbosity();
     $manager = $this->getCreatorsManager();
     $conf = $manager->getConfig();
     if (isset($conf['definitions'])) {
         $output->writeln('Start creating definitions...');
         $manager->createDefinitions($conf['definitions'], $output);
         $output->writeln('Finish creating definitions.');
     } else {
         $output->writeln('');
         $output->writeln('WARNING: definitions not found');
     }
     if (isset($conf['paths'])) {
         $output->writeln('Start creating controllers...');
         $buildRoutingAnnotations = 'annotation' === $manager->getRoutingType();
         $manager->createControllers($conf['paths'], $buildRoutingAnnotations, $output);
         $output->writeln('Finish creating controllers.');
         if ('yaml' == $manager->getRoutingType()) {
             $output->writeln('Start creating routing yaml file...');
             $manager->createRoutingYamlFile($conf['paths'], $output);
             $output->writeln('Finish creating routing yaml file.');
         }
     } else {
         $output->writeln('');
         $output->writeln('WARNING: paths not found');
     }
     //security:
     $security = isset($conf['security']) ? $conf['security'] : null;
     $paths = isset($conf['paths']) ? $conf['paths'] : array();
     $manager->createSecurityYamlFile($conf['basePath'], $security, $paths, $output);
     $output->writeln('Finish creating security yaml file.');
     if (!$input->getOption('no-csfixer')) {
         $watcher = new Stopwatch();
         $eventDispatcher = new EventDispatcher();
         $dirs = array($manager->getOutputPath() . 'Controller/Api/', $manager->getOutputPath() . 'Api/Model');
         $fixer = new fixer();
         $fixer->setStopwatch(new Stopwatch());
         $fixer->registerBuiltInFixers();
         $fixer->registerBuiltInConfigs();
         $config = new config();
         $config->fixers($fixer->getFixers());
         foreach ($dirs as $dir) {
             if (file_exists($dir) && is_dir($dir)) {
                 $config->getFinder()->setDir($dir);
             }
         }
         $fileProcessedEventListener = function (FixerFileProcessedEvent $event) use($output) {
             $output->write($event->getStatusAsString());
         };
         $fixer->setEventDispatcher($eventDispatcher);
         $eventDispatcher->addListener(FixerFileProcessedEvent::NAME, $fileProcessedEventListener);
         $watcher->start('fixFiles');
         $changed = $fixer->fix($config);
         $watcher->stop('fixFiles');
         $fixer->setEventDispatcher(null);
         $eventDispatcher->removeListener(FixerFileProcessedEvent::NAME, $fileProcessedEventListener);
         $output->writeln('');
         $legend = array();
         foreach (FixerFileProcessedEvent::getStatusMap() as $status) {
             if ($status['symbol'] && $status['description']) {
                 $legend[] = $status['symbol'] . '-' . $status['description'];
             }
         }
         $output->writeln('Legend: ' . implode(', ', array_unique($legend)));
         if (OutputInterface::VERBOSITY_VERBOSE <= $verbosity) {
             $i = 1;
             foreach ($changed as $file => $fixResult) {
                 $output->writeln(sprintf('%4d) %s', $i++, $file));
             }
             $output->writeln('');
             $fixEvent = $watcher->getEvent('fixFiles');
             $output->writeln(sprintf('Fixed all files in %.3f seconds, %.3f MB memory used', $fixEvent->getDuration() / 1000, $fixEvent->getMemory() / 1024 / 1024));
         }
     }
 }
開發者ID:enneite,項目名稱:swagger-bundle,代碼行數:88,代碼來源:GenerateCommand.php


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