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


PHP SymfonyStyle::note方法代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $this->destinationPath = $input->getArgument('destination');
     $this->version = $input->getArgument('version');
     if (file_exists($this->destinationPath)) {
         throw new \InvalidArgumentException(sprintf('The directory %s already exists', $this->destinationPath));
     }
     $this->filesystem = new Filesystem();
     $io->writeln(PHP_EOL . ' Downloading Majora Standard Edition...' . PHP_EOL);
     $this->download($output);
     $io->writeln(PHP_EOL . PHP_EOL . ' Preparing project...' . PHP_EOL);
     $io->note('Extracting...');
     $this->extract();
     $io->note('Installing dependencies (this operation may take a while)...');
     $outputCallback = null;
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERY_VERBOSE) {
         $outputCallback = function ($type, $buffer) use($output) {
             $output->write($buffer);
         };
     }
     $this->installComposerDependencies($outputCallback);
     $io->note('Cleaning...');
     $this->clean();
     $io->success([sprintf('Majora Standard Edition %s was successfully installed', $this->version)]);
 }
开发者ID:LinkValue,项目名称:MajoraInstaller,代码行数:29,代码来源:NewCommand.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $receipts = Yaml::parse(file_get_contents($input->getArgument('tasks-file')));
     $io = new SymfonyStyle($input, $output);
     foreach ($receipts['instances'] as $key => $instance) {
         $fs = new Filesystem();
         $tmpTime = sys_get_temp_dir() . "/backup_" . time();
         if ($fs->exists($tmpTime)) {
             $fs->remove($tmpTime);
         }
         $fs->mkdir($tmpTime);
         $this->tmpTime = $tmpTime;
         $io->note("Save : " . $key);
         /**
          * Save the database if is defined
          */
         $this->backupDatabase($io, $key, $instance);
         /**
          * Save the directories and compress if is defined
          */
         $this->backupDirectories($io, $key, $instance);
         $fileCompressedPath = $this->compress($io, $key, $instance);
         $hashFile = $this->generateHashFile($fileCompressedPath);
         $filesForCloud = [$fileCompressedPath, $hashFile];
         if (!array_key_exists('storages', $instance['processor'])) {
             throw new \RuntimeException("You storages is not defined");
         }
         $cloudStorage = new CloudStorage($io, $instance['processor']['storages'], $instance['cloud_storages'], $key, $filesForCloud);
         $cloudStorage->execute();
     }
 }
开发者ID:PiktalentCom,项目名称:backup,代码行数:31,代码来源:BackupCommand.php

示例3: execute

 /**
  * {@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);
 }
开发者ID:edetaillac,项目名称:static-review,代码行数:36,代码来源:CheckRequirementsCommand.php

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

示例5: execute

 /**
  * @{inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->application = $this->getApplication()->getApplication();
     $this->fixtureLoader = $this->getContainer()->get('demo.website_loader');
     $this->dataRepository = $this->getBundle()->getBaseDirectory() . DIRECTORY_SEPARATOR . 'Data' . DIRECTORY_SEPARATOR;
     $output = new SymfonyStyle($input, $output);
     $output->title('BackBee Demonstration Website Importer');
     $output->progressStart(3);
     $lines = $this->loadFixtures();
     $output->progressAdvance();
     $output->note('✓ Updated BackBee Application');
     $website = $this->updateWebsite();
     $output->progressAdvance();
     $output->note(sprintf('✓ Updated Domain to ``%s`` with label ``%s``', $website['domain'], $website['label']));
     $this->importAssets();
     $output->progressAdvance();
     $output->note('✓ Imported pictures assets');
     $output->newline();
     $output->success('Website loaded with success.');
 }
开发者ID:Amalec78,项目名称:DemoBundle,代码行数:23,代码来源:LoadDemoWebsiteCommand.php

示例6: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     $queue = $this->queueFactory->createQueue($input->getArgument('queue'));
     if ($input->isInteractive()) {
         if (!$output->confirm(sprintf(static::CONFIRM_MSG, $queue->getName()), false)) {
             return;
         }
     }
     $count = $this->queueRegistry->deregister($queue);
     $output->success('Deleted queue "' . $queue->getName() . '"');
     if ($count) {
         $output->note('Removed ' . $count . ' jobs.');
     }
 }
开发者ID:php-resque,项目名称:resque-bundle,代码行数:15,代码来源:QueueDeleteCommand.php

示例7: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io = new SymfonyStyle($input, $output);
     $this->io->block('Running server...');
     $verbosity = $this->io->getVerbosity();
     switch ($verbosity) {
         case 16:
             $verbosity = 'quiet';
             break;
         case 32:
             $verbosity = 'normal';
             break;
         case 64:
             $verbosity = 'verbose';
             break;
         case 128:
             $verbosity = 'very_verbose';
             break;
         case 256:
             $verbosity = 'debug';
             break;
     }
     $this->io->note('Verbosity is "' . $verbosity . '". To set verbosity, add "-v", "-vv" or "-vvv" end the end of this command.');
     $this->socketPort = $this->getContainer()->getParameter('socket_port');
     $em = $this->getContainer()->get('doctrine.orm.default_entity_manager');
     $logger = $this->getContainer()->get('logger');
     $socketUrl = $this->getContainer()->getParameter('socket_server_url');
     $webUrl = $this->getContainer()->getParameter('web_server_url');
     $webHooks = $em->getRepository('AppBundle:WebHook')->findAll();
     $logger->info(count($webHooks) . ' webHook(s)');
     $server = new Server($em, $webHooks, $webUrl, $socketUrl, $logger);
     $this->killExistingSocketServer();
     $ioServer = IoServer::factory(new HttpServer(new WsServer($server)), $this->socketPort);
     $logger->info('Run socket server on port ' . $this->socketPort . '...');
     $ioServer->run();
 }
开发者ID:localhook,项目名称:localhook-server,代码行数:36,代码来源:RunSocketCommand.php

示例8: execute

 /**
  * @param InputInterface         $input
  * @param OutputInterface|Output $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->getLogger()->debug('Start', ['command_name' => $this->getName(), 'args' => $input->getArguments(), 'opts' => $input->getOptions()]);
     $optionDryRun = $input->getOption('dry-run');
     $repositories = $this->getRepositoryModelList();
     $projectModel = $repositories->getProjectModel();
     $xmlFilename = implode(DIRECTORY_SEPARATOR, [$projectModel->getAbsolutePath(), '.idea', 'vcs.xml']);
     $fileSystem = new Filesystem();
     if (!$fileSystem->exists($xmlFilename)) {
         $this->getSymfonyStyle()->error(sprintf('Config file "%s" not found', $xmlFilename));
     }
     $existsMap = [];
     $simpleXml = simplexml_load_file($xmlFilename);
     foreach ($simpleXml->component->children() as $child) {
         /** @var \SimpleXMLElement $child */
         $existsMap[] = (string) $child->attributes()['directory'];
     }
     $vendors = [];
     foreach ($this->getRepositoryModelList()->getAll() as $model) {
         $tmp = '$PROJECT_DIR$';
         if ($model->getPath()) {
             $tmp .= DIRECTORY_SEPARATOR . $model->getPath();
         }
         $vendors[] = $tmp;
     }
     $symfonyStyle = new SymfonyStyle($input, $output);
     $newDirs = array_diff($vendors, $existsMap);
     if (count($newDirs)) {
         $question = sprintf('Script will add %d new dirs, would you like to continue?', count($newDirs));
         if ($symfonyStyle->confirm($question, true)) {
             foreach ($newDirs as $dir) {
                 $mapping = $simpleXml->component->addChild('mapping', '');
                 $mapping->addAttribute('directory', $dir);
                 $mapping->addAttribute('vcs', 'Git');
             }
             $dom = dom_import_simplexml($simpleXml)->ownerDocument;
             $dom->preserveWhiteSpace = false;
             $dom->formatOutput = true;
             if (!$optionDryRun) {
                 $fileSystem->dumpFile($xmlFilename, $dom->saveXML());
             }
             $symfonyStyle->success(sprintf('File "%s" updated', $xmlFilename));
         }
     } else {
         $symfonyStyle->note('Changes not found');
     }
     $this->getLogger()->debug('Finish', ['command_name' => $this->getName()]);
 }
开发者ID:octava,项目名称:geggs,代码行数:53,代码来源:IdeaVcsUpdateCommand.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $git = new GitVersionControl();
     $stagedFiles = $git->getStagedFiles();
     $projectBase = $git->getProjectBase();
     $reporter = new Reporter($output, count($stagedFiles));
     $review = new StaticReview($reporter);
     $review->addReview(new ComposerLockReview())->addReview(new ComposerLintReview())->addReview(new PhpLintReview())->addReview(new PhpStopWordsReview())->addReview(new JsStopWordsReview())->addReview(new EsLintReview(self::AUTO_ADD_GIT))->addReview(new YmlLintReview())->addReview(new JsonLintReview())->addReview(new XmlLintReview())->addReview(new GitConflictReview());
     // --------------------------------------------------------
     // Front Dev profile
     // --------------------------------------------------------
     /*$review->addReview(new ScssLintReview())
       ->addReview(new SassConvertFixerReview(self::AUTO_ADD_GIT));*/
     // --------------------------------------------------------
     // Dev PHP profile
     // --------------------------------------------------------
     $phpCodeSniffer = new PhpCodeSnifferReview();
     $phpCodeSniffer->setOption('standard', 'Pear');
     $phpCodeSniffer->setOption('sniffs', 'PEAR.Commenting.FunctionComment');
     $review->addReview(new PhpCPDReview())->addReview(new PhpMDReview())->addReview($phpCodeSniffer);
     // --------------------------------------------------------
     $review->files($stagedFiles);
     $reporter->displayReport();
     $testingReporter = new Reporter($output, 0);
     // --------------------------------------------------------
     // Dev PHP profile
     // --------------------------------------------------------
     if (!$reporter->hasIssueLevel(Issue::LEVEL_ERROR) && count($stagedFiles) > 0) {
         $testingReview = new TestingReview($testingReporter);
         if ($input->getOption('phpunit')) {
             $testingReview->addReview(new PhpUnitReview($input->getOption('phpunit-bin-path'), $input->getOption('phpunit-conf'), $projectBase));
         }
         $testingReview->review();
         $testingReporter->displayReport();
     }
     // --------------------------------------------------------
     if ($reporter->hasIssueLevel(Issue::LEVEL_ERROR) || $testingReporter->hasIssueLevel(Issue::LEVEL_ERROR)) {
         $io->error('✘ Please fix the errors above or use --no-verify.');
         exit(1);
     } elseif ($reporter->hasIssueLevel(Issue::LEVEL_WARNING) || $testingReporter->hasIssueLevel(Issue::LEVEL_WARNING)) {
         $io->note('Try to fix warnings !');
     } else {
         $io->success('✔ Looking good.');
     }
     exit(0);
 }
开发者ID:edetaillac,项目名称:static-review,代码行数:50,代码来源:PreCommitCommand.php

示例10: lock

 /**
  * Lock the TYPO3 Backend
  *
  * @param SymfonyStyle $io
  * @param InputInterface $input
  */
 protected function lock(SymfonyStyle $io, InputInterface $input)
 {
     $lockFile = $this->getLockFileName();
     if (@is_file($lockFile)) {
         $io->note('A lock file already exists. Overwriting it.');
     }
     $output = 'Wrote lock file to "' . $lockFile . '"';
     if ($input->getArgument('redirect')) {
         $lockFileContent = $input->getArgument('redirect');
         $output .= LF . 'with content "' . $lockFileContent . '".';
     } else {
         $lockFileContent = '';
         $output .= '.';
     }
     GeneralUtility::writeFile($lockFile, $lockFileContent);
     $io->success($output);
 }
开发者ID:TYPO3Incubator,项目名称:TYPO3.CMS,代码行数:23,代码来源:LockBackendCommand.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Pre-commit install');
     $git = new GitVersionControl();
     $projectBase = $git->getProjectBase();
     $phpunit = $io->confirm('Enable PhpUnit ?', true);
     $source = realpath($projectBase);
     $hookDir = $source . '/.git/hooks';
     $defaultPhpUnitConfFile = $source . '/' . self::PHPUNIT_DEFAULT_CONF_FILENAME;
     $precommitCommand = sprintf('precommit check%s', $phpunit ? ' --phpunit true' : '');
     if ($phpunit) {
         $phpunitPath = $io->ask('Specify Phpunit bin path [example: vendor/bin/phpunit] ? : ', 'phpunit');
         $phpunitConfFile = $io->ask('Specify Phpunit config file path ? : ', $defaultPhpUnitConfFile);
         if ($phpunitPath != '') {
             if (strpos($phpunitPath, '/') !== false) {
                 $phpunitPath = $source . '/' . $phpunitPath;
                 if (!is_file($phpunitPath)) {
                     $io->error(sprintf('No phpunit bin found "%s"', $phpunitPath));
                     exit(1);
                 }
             }
         }
         if (!is_file($phpunitConfFile)) {
             $io->error(sprintf('No phpunit conf file found "%s"', $phpunitConfFile));
             exit(1);
         }
         $precommitCommand .= $phpunitPath != 'phpunit' ? ' --phpunit-bin-path ' . $phpunitPath : '';
         $precommitCommand .= $phpunitConfFile != $defaultPhpUnitConfFile ? ' --phpunit-conf ' . $phpunitConfFile : '';
     }
     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)) {
         $fileContent = sprintf("#!/bin/sh\n%s", $precommitCommand);
         $fs->dumpFile($target, $fileContent);
         chmod($target, 0755);
         $io->success('pre-commit file correctly updated');
     } else {
         $io->note(sprintf('A pre-commit file is already exist. Please add "%s" at the end !', $precommitCommand));
     }
     exit(0);
 }
开发者ID:edetaillac,项目名称:static-review,代码行数:49,代码来源:HookInstallCommand.php

示例12: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Pre-commit workspace check');
     $this->workspacePath = $input->getArgument('path');
     if ($this->workspacePath == '') {
         $helper = $this->getHelperSet()->get('question');
         $question = new Question('Specify your full workspace directory path please : ', '');
         $this->workspacePath = $helper->ask($input, $output, $question);
     }
     $this->workspacePath .= substr($this->workspacePath, -1) != '/' ? '/' : '';
     if (!is_dir($this->workspacePath)) {
         $io->error(sprintf('The workspace directory does not exist (%s)', $this->workspacePath));
         exit(1);
     }
     $output->write('Analyse en cours ... ');
     $finder = new Finder();
     $finder = $finder->directories()->ignoreUnreadableDirs()->ignoreDotFiles(false)->ignoreVCS(false)->in($this->workspacePath);
     $finder = $finder->notpath('/\\/vendor\\//')->notpath('/\\/log[s]?\\//')->notpath('/\\/cache\\//')->path('/.git\\/config/');
     $projects = array();
     $files = $finder->files();
     if (count($files) > 0) {
         $progress = new ProgressBar($output, count($files));
         $progress->setFormat('normal');
         $progress->start();
         foreach ($finder->files() as $file) {
             $precommitStatus = $this->getPrecommitStatus($file);
             $projectInfoPath = explode('/', str_replace('/.git', '', $file->getPathInfo()->getPathname()));
             $projects[] = array('name' => end($projectInfoPath), 'path' => str_replace('/.git', '', $this->workspacePath . $file->getRelativePath()), 'precommit' => $precommitStatus);
             $progress->advance();
         }
         $progress->finish();
         $output->writeln('');
         $output->writeln('');
     }
     if (count($projects) > 0) {
         $this->displayProjects($projects, $output);
     } else {
         $io->note('No GIT repositories found');
     }
     exit(0);
 }
开发者ID:edetaillac,项目名称:static-review,代码行数:45,代码来源:HookListCommand.php

示例13: displayResults

 /**
  * Displays a security report as plain text.
  *
  * @param OutputInterface $output
  * @param string          $lockFilePath    The file path to the checked lock file
  * @param array           $vulnerabilities An array of vulnerabilities
  */
 public function displayResults(OutputInterface $output, $lockFilePath, array $vulnerabilities)
 {
     $output = new SymfonyStyle(new ArrayInput(array()), $output);
     $output->title('Symfony Security Check Report');
     $output->comment(sprintf('Checked file: <comment>%s</>', realpath($lockFilePath)));
     if ($count = count($vulnerabilities)) {
         $output->error(sprintf('%d packages have known vulnerabilities.', $count));
     } else {
         $output->success('No packages have known vulnerabilities.');
     }
     if (0 !== $count) {
         foreach ($vulnerabilities as $dependency => $issues) {
             $output->section(sprintf('%s (%s)', $dependency, $issues['version']));
             $details = array_map(function ($value) {
                 return sprintf("<info>%s</>: %s\n   %s", $value['cve'] ?: '(no CVE ID)', $value['title'], $value['link']);
             }, $issues['advisories']);
             $output->listing($details);
         }
     }
     $output->note('This checker can only detect vulnerabilities that are referenced in the SensioLabs security advisories database. Execute this command regularly to check the newly discovered vulnerabilities.');
 }
开发者ID:sensiolabs,项目名称:security-checker,代码行数:28,代码来源:TextFormatter.php

示例14: createServerManagers

 private function createServerManagers()
 {
     /** @var Discord $discord */
     /* @var ObjectManager $manager */
     $discord = $this->getContainer()->get('discord');
     $manager = $this->getContainer()->get('default_manager');
     $repo = $manager->getRepository($this->getContainer()->getParameter('server_class'));
     /** @var Collection $servers */
     $servers = $discord->guilds;
     $ids = [];
     foreach ($discord->guilds as $guild) {
         $ids[] = $guild->id;
     }
     $dbServers = $repo->findBy(['identifier' => $ids]);
     $this->output->text('Creating server managers for ' . $servers->count() . ' servers.');
     $this->output->progressStart($servers->count());
     /** @var ServerManagerFactory $factory */
     $factory = $this->getContainer()->get('factory.server_manager');
     foreach ($discord->guilds as $server) {
         $dbServer = $this->findDbServer($dbServers, $server);
         try {
             $this->serverManagers[] = $factory->create($server, $dbServer);
         } catch (\Exception $e) {
             $this->output->progressFinish();
             $this->logError($e->getMessage());
             exit(0);
         }
         $this->output->progressAdvance();
     }
     $this->output->progressFinish();
     $delay = $this->getContainer()->getParameter('database_save_delay');
     if ($delay !== false) {
         $this->getContainer()->get('default_manager')->flush();
         $discord->loop->addPeriodicTimer($delay, function () {
             $this->output->note('Saving current UoW to database.');
             $this->getContainer()->get('default_manager')->flush();
         });
     }
 }
开发者ID:lfgamers,项目名称:discord-base-bot,代码行数:39,代码来源:RunCommand.php

示例15: prepareReportOperationJobs

 protected function prepareReportOperationJobs()
 {
     /** @var SchedulerReportOperation[] $scheduledReports */
     $scheduledReports = $this->em->getRepository('CampaignChainCoreBundle:SchedulerReportOperation')->getScheduledReportJobsForSchedulerCommand($this->scheduler->getPeriodStart(), $this->scheduler->getPeriodEnd());
     if (empty($scheduledReports)) {
         $this->io->text('No scheduled Operation reports.');
         $this->logger->info('No scheduled Operation reports.');
         return;
     }
     // Queue the scheduled reports.
     $this->io->text('Processing scheduled Operation reports.');
     $this->logger->info('Processing scheduled Operation reports.');
     foreach ($scheduledReports as $scheduledReport) {
         $txt = 'Report ID: ' . $scheduledReport->getId();
         $this->io->section($txt);
         $this->logger->info($txt);
         // Check whether the Action's end date has been modified
         // since we last ran this report job.
         $endDateChanged = false;
         if ($scheduledReport->getEndAction() != $scheduledReport->getEndDate()) {
             /*
              * This flag will ensure that the report job will be
              * executed so that it can handle the end date change.
              */
             $endDateChanged = true;
             // Update end date of report scheduler entry to Action's end date.
             $newEndDate = clone $scheduledReport->getEndAction();
             $scheduledReport->setEndDate($newEndDate);
             $txt = "Action's end date changed to " . $newEndDate->format(\DateTime::ISO8601);
             $this->io->note($txt);
             $this->logger->info($txt);
         }
         // Check whether we're past the prolonged end date if defined.
         if ($scheduledReport->getProlongation() != null) {
             $this->io->text('Prolongation: ' . $scheduledReport->getProlongation());
             $interval = \DateInterval::createFromDateString($scheduledReport->getProlongation());
             $prolongedEndDate = clone $scheduledReport->getEndDate();
             $prolongedEndDate->add($interval);
             // Prolonged end date is older than now.
             if ($prolongedEndDate < $this->now) {
                 if (!$endDateChanged) {
                     $txt = 'Past prolongation period. Skipping this report job.';
                     $this->io->text($txt);
                     $this->logger->info($txt);
                     // Don't execute this report job.
                     continue;
                 } else {
                     $txt = "Past prolongation period and end date changed. We'll let the report job handle this.";
                     $this->io->text($txt);
                     $this->logger->info($txt);
                 }
             }
             // No prolongation, so check if end date is older than next run.
         } elseif ($scheduledReport->getEndDate() < $scheduledReport->getNextRun()) {
             if (!$endDateChanged) {
                 $txt = 'No prolongation and past end date. Skipping this report job.';
                 $this->io->text($txt);
                 $this->logger->info($txt);
                 continue;
             } else {
                 $txt = "No prolongation and past end date, but end date changed. We'll let the report job handle this.";
                 $this->io->text($txt);
                 $this->logger->info($txt);
             }
         }
         $this->queueReportJob($scheduledReport);
         /*
          * Update next run.
          */
         // Are we within the regular scheduled period?
         if ($scheduledReport->getEndDate() > $this->now && $scheduledReport->getInterval() != null) {
             $interval = \DateInterval::createFromDateString($scheduledReport->getInterval());
             $nextRun = clone $scheduledReport->getNextRun();
             $scheduledReport->setNextRun($nextRun->add($interval));
             $txt = 'Regular period. Next run is in ' . $scheduledReport->getInterval();
             $this->io->text($txt);
             $this->logger->info($txt);
             // ... or are we within the prolonged period?
         } elseif (isset($prolongedEndDate) && $prolongedEndDate > $this->now && $scheduledReport->getProlongationInterval() != null) {
             $interval = \DateInterval::createFromDateString($scheduledReport->getProlongationInterval());
             /*
              * The prolongation interval starts with the end date.
              * Hence, if this is the first interval within the
              * prolonged period, then we add the interval on top of
              * the end date. If not, then on top of the next run date.
              */
             if ($scheduledReport->getNextRun() < $scheduledReport->getEndDate()) {
                 $nextRun = clone $scheduledReport->getEndDate();
             } else {
                 $nextRun = clone $scheduledReport->getNextRun();
             }
             $scheduledReport->setNextRun($nextRun->add($interval));
             $txt = 'Prolonged period. Next run is in ' . $scheduledReport->getProlongationInterval();
             $this->io->text($txt);
             $this->logger->info($txt);
         }
         $this->em->persist($scheduledReport);
     }
     //update the next run dates for the scheduler
     $this->em->flush();
//.........这里部分代码省略.........
开发者ID:CampaignChain,项目名称:core,代码行数:101,代码来源:SchedulerCommand.php


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