newLine() public method

public newLine ( $count = 1 )
Esempio n. 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $show_installed = !$input->getOption('available');
     $installed = $available = array();
     foreach ($this->load_migrations() as $name) {
         if ($this->migrator->migration_state($name) !== false) {
             $installed[] = $name;
         } else {
             $available[] = $name;
         }
     }
     if ($show_installed) {
         $io->section($this->user->lang('CLI_MIGRATIONS_INSTALLED'));
         if (!empty($installed)) {
             $io->listing($installed);
         } else {
             $io->text($this->user->lang('CLI_MIGRATIONS_EMPTY'));
             $io->newLine();
         }
     }
     $io->section($this->user->lang('CLI_MIGRATIONS_AVAILABLE'));
     if (!empty($available)) {
         $io->listing($available);
     } else {
         $io->text($this->user->lang('CLI_MIGRATIONS_EMPTY'));
         $io->newLine();
     }
 }
 public function writeErrorReports(array $errorReports)
 {
     foreach ($errorReports as $file => $errors) {
         $this->symfonyStyle->section('FILE: ' . $file);
         $tableRows = $this->formatErrorsToTableRows($errors);
         $this->symfonyStyle->table(['Line', 'Error', 'Sniff Code', 'Fixable'], $tableRows);
         $this->symfonyStyle->newLine();
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function executeLocked(InputInterface $input, OutputInterface $output)
 {
     $this->io = new SymfonyStyle($input, $output);
     $this->rootDir = dirname($this->getContainer()->getParameter('kernel.root_dir'));
     $this->generateSymlinks();
     if (!empty($this->rows)) {
         $this->io->newLine();
         $this->io->table(['', 'Symlink', 'Target / Error'], $this->rows);
     }
     return 0;
 }
Esempio n. 4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $basePath = Application::basePath();
     chdir($basePath);
     $host = $input->getOption('host');
     $port = $input->getOption('port');
     $base = ProcessUtils::escapeArgument($basePath);
     $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder())->find(false));
     $io = new SymfonyStyle($input, $output);
     $io->newLine();
     $io->writeln('<info>Tagmeo development server started on http://' . $host . ':' . $port . '/</info>');
     $io->newLine();
     passthru($binary . ' -S ' . $host . ':' . $port . ' ' . $base . '/server.php');
 }
 /**
  * {@inheritdoc}
  */
 protected function executeLocked(InputInterface $input, OutputInterface $output)
 {
     $this->fs = new Filesystem();
     $this->io = new SymfonyStyle($input, $output);
     $this->rootDir = dirname($this->getContainer()->getParameter('kernel.root_dir'));
     $this->addEmptyDirs();
     $this->addIgnoredDirs();
     if (!empty($this->rows)) {
         $this->io->newLine();
         $this->io->listing($this->rows);
     }
     $this->addInitializePhp();
     return 0;
 }
Esempio n. 6
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     $this->io->text("removing articles\n");
     $this->removeArticles();
     $this->io->newLine(2);
     $this->io->text("refresh journal and remove issues\n");
     $this->removeIssues($input);
     $this->io->newLine(1);
     $this->io->text("refresh journal and remove journal totally");
     $this->refreshJournal($input);
     $this->em->remove($this->journal);
     $this->em->flush();
     $this->io->success('successfully removed journal');
 }
 /**
  * @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));
 }
Esempio n. 8
0
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     $this->io->text('Issue Total View Normalize Started');
     $this->normalizeIssueTotalArticleView();
     $this->io->text('Issue Total Download Normalize Started');
     $this->normalizeIssueTotalArticleDownload();
     $this->io->newLine();
     $this->io->text('Journal Normalize Started');
     $this->normalizeJournalTotalArticleView();
     $this->io->text('Journal Total View Normalize Finished');
     $this->normalizeJournalTotalArticleDownload();
     $this->io->text('Journal Total Download Normalize Finished');
     $this->io->newLine(2);
     $this->io->success('All process finished');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Exporting databases');
     $io->section('Exporting all databases');
     $strategies = $this->collectorDbStrategy->collectDatabasesStrategies();
     $totalStrategies = count($strategies);
     $io->writeln($totalStrategies . ' strategie(s) found.');
     $progressBar = new ProgressBar($output, $totalStrategies);
     $progressBar->setFormat(self::PROGRESS_BAR_FORMAT);
     $progressBar->setMessage('Beginning backuping');
     $this->eventDispatcher->dispatch(Events::BACKUP_BEGINS, new BackupBeginsEvent($output));
     $progressBar->start();
     $reportContent = new \ArrayObject();
     foreach ($strategies as $strategy) {
         $strategyIdentifier = $strategy->getIdentifier();
         $setProgressBarMessage = function ($message) use($progressBar, $strategyIdentifier) {
             $message = "[{$strategyIdentifier}] {$message}";
             $progressBar->setMessage($message);
             $progressBar->display();
         };
         $exportedFiles = $this->processorDatabaseDumper->dump($strategy, $setProgressBarMessage);
         $reportContent->append("Backuping of the database: {$strategyIdentifier}");
         foreach ($exportedFiles as $file) {
             $filename = $file->getPath();
             $reportContent->append("\t→ {$filename}");
         }
         $progressBar->advance();
     }
     $progressBar->finish();
     $io->newLine(2);
     $io->section('Report');
     $io->text($reportContent->getArrayCopy());
     $this->eventDispatcher->dispatch(Events::BACKUP_ENDS, new BackupEndsEvent($output));
 }
Esempio n. 10
0
 /**
  * Create a styled progress bar
  *
  * @param int             $max     Max value for the progress bar
  * @param SymfonyStyle    $io      Symfony style output decorator
  * @param OutputInterface $output  The output stream, used to print messages
  * @param bool            $message Should we display message output under the progress bar?
  * @return ProgressBar
  */
 public function create_progress_bar($max, SymfonyStyle $io, OutputInterface $output, $message = false)
 {
     $progress = $io->createProgressBar($max);
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
         $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
         $progress->setOverwrite(false);
     } else {
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
             $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
             $progress->setOverwrite(false);
         } else {
             $io->newLine(2);
             $progress->setFormat("    %current:s%/%max:s% %bar%  %percent:3s%%\n" . "        " . ($message ? '%message%' : '                ') . " %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
             $progress->setBarWidth(60);
         }
     }
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $progress->setEmptyBarCharacter('░');
         // light shade character \u2591
         $progress->setProgressCharacter('');
         $progress->setBarCharacter('▓');
         // dark shade character \u2593
     }
     return $progress;
 }
Esempio n. 11
0
 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.');
 }
Esempio n. 12
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $io->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()) {
         $io->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $io->title(sprintf('Current configuration for "%s"', $name));
     }
     $io->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
Esempio n. 13
0
 /**
  * {@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));
 }
Esempio n. 14
0
 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);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @throws \LogicException
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = $input->getArgument('name');
     if (empty($name)) {
         $io->comment('Provide the name of a bundle as the first argument of this command to dump its default configuration.');
         $io->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $configuration = $extension->getConfiguration(array(), $this->getContainerBuilder());
     $this->validateConfiguration($extension, $configuration);
     if ($name === $extension->getAlias()) {
         $message = sprintf('Default configuration for extension with alias: "%s"', $name);
     } else {
         $message = sprintf('Default configuration for "%s"', $name);
     }
     switch ($input->getOption('format')) {
         case 'yaml':
             $io->writeln(sprintf('# %s', $message));
             $dumper = new YamlReferenceDumper();
             break;
         case 'xml':
             $io->writeln(sprintf('<!-- %s -->', $message));
             $dumper = new XmlReferenceDumper();
             break;
         default:
             $io->writeln($message);
             throw new \InvalidArgumentException('Only the yaml and xml formats are supported.');
     }
     $io->writeln($dumper->dump($configuration, $extension->getNamespace()));
 }
Esempio n. 16
0
 /**
  * {@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;
     }
 }
Esempio n. 17
0
 /**
  * Reparse all text handled by given reparser within given range
  *
  * @param string $name Reparser name
  */
 protected function reparse($name)
 {
     $reparser = $this->reparsers[$name];
     if ($this->input->getOption('dry-run')) {
         $reparser->disable_save();
     } else {
         $reparser->enable_save();
     }
     // Start at range-max if specified or at the highest ID otherwise
     $max = $this->get_option($name, 'range-max');
     $min = $this->get_option($name, 'range-min');
     $size = $this->get_option($name, 'range-size');
     if ($max < $min) {
         return;
     }
     $this->io->section($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', preg_replace('(^text_reparser\\.)', '', $name), $min, $max));
     $progress = $this->create_progress_bar($max);
     $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING_START', preg_replace('(^text_reparser\\.)', '', $name)));
     $progress->start();
     // Start from $max and decrement $current by $size until we reach $min
     $current = $max;
     while ($current >= $min) {
         $start = max($min, $current + 1 - $size);
         $end = max($min, $current);
         $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', preg_replace('(^text_reparser\\.)', '', $name), $start, $end));
         $reparser->reparse_range($start, $end);
         $current = $start - 1;
         $progress->setProgress($max + 1 - $start);
         $this->update_resume_data($name, $current);
     }
     $progress->finish();
     $this->io->newLine(2);
 }
Esempio n. 18
0
 /**
  * @param Journal $journal
  * @return bool|null
  */
 private function normalizeLastIssuesByJournal(Journal $journal)
 {
     $this->io->newLine();
     $this->io->text('normalizing last issue for ' . $journal->getTitle());
     $this->io->progressAdvance();
     $findLastIssue = $this->em->getRepository('OjsJournalBundle:Issue')->findOneBy(['journal' => $journal, 'lastIssue' => true]);
     if ($findLastIssue) {
         return true;
     }
     /** @var Issue|null $getLogicalLastIssue */
     $getLogicalLastIssue = $this->em->getRepository('OjsJournalBundle:Issue')->getLastIssueByJournal($journal);
     if ($getLogicalLastIssue == null) {
         return null;
     }
     $getLogicalLastIssue->setLastIssue(true);
     $this->em->flush();
 }
Esempio n. 19
0
 /**
  * @return bool|null
  */
 private function validateEntities()
 {
     $this->io->newLine();
     $this->io->text('Validation Starting for all entities');
     $metas = $this->em->getMetadataFactory()->getAllMetadata();
     /** @var ClassMetadata $meta */
     foreach ($metas as $meta) {
         if ($meta->isMappedSuperclass) {
             continue;
         }
         $reflClass = $meta->getReflectionClass();
         if ($reflClass->hasMethod('__toString')) {
             $this->io->text(sprintf('%s %s -> have __toString function', $this->os->okSign(), $meta->getName()));
         } else {
             $this->io->text(sprintf('%s %s -> have not __toString function', $this->os->warningSign(), $meta->getName()));
         }
     }
 }
 /**
  * @inheritDoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = new SymfonyStyle($input, $output);
     $helper->title('Doctrine');
     $choices = [self::ACTION_DATABASE_IMPORT => 'Import database from remote host'];
     $todo = $helper->choice('Select action', $choices);
     $helper->newLine(4);
     $helper->section($choices[$todo]);
     $this->executeChoice($helper, $todo);
     CommandUtility::writeFinishedMessage($helper, self::NAME);
 }
Esempio n. 21
0
 /**
  * @inheritDoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $helper = new SymfonyStyle($input, $output);
     $helper->title('FOSUserBundle');
     $choices = [self::ACTION_PASSWORD_REPLACE => 'Replace all passwords (be careful!)'];
     $todo = $helper->choice('Select action', $choices);
     $helper->newLine(4);
     $helper->section($choices[$todo]);
     $this->executeChoice($helper, $todo);
     CommandUtility::writeFinishedMessage($helper, self::NAME);
 }
Esempio n. 22
0
 /**
  * Reparse all text handled by given reparser within given range
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @param string $name Reparser name
  * @return null
  */
 protected function reparse(InputInterface $input, OutputInterface $output, $name)
 {
     $reparser = $this->reparsers[$name];
     if ($input->getOption('dry-run')) {
         $reparser->disable_save();
     } else {
         $reparser->enable_save();
     }
     // Start at range-max if specified or at the highest ID otherwise
     $max = is_null($input->getOption('range-max')) ? $reparser->get_max_id() : $input->getOption('range-max');
     $min = $input->getOption('range-min');
     $size = $input->getOption('range-size');
     if ($max === 0) {
         return;
     }
     $this->io->section($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', str_replace('text_reparser.', '', $name), $min, $max));
     $progress = $this->io->createProgressBar($max);
     if ($output->getVerbosity() === OutputInterface::VERBOSITY_VERBOSE) {
         $progress->setFormat('<info>[%percent:3s%%]</info> %message%');
         $progress->setOverwrite(false);
     } else {
         if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE) {
             $progress->setFormat('<info>[%current:s%/%max:s%]</info><comment>[%elapsed%/%estimated%][%memory%]</comment> %message%');
             $progress->setOverwrite(false);
         } else {
             $this->io->newLine(2);
             $progress->setFormat("    %current:s%/%max:s% %bar%  %percent:3s%%\n" . "        %message% %elapsed:6s%/%estimated:-6s% %memory:6s%\n");
             $progress->setBarWidth(60);
         }
     }
     $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING_START', str_replace('text_reparser.', '', $name)));
     if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
         $progress->setEmptyBarCharacter('░');
         // light shade character \u2591
         $progress->setProgressCharacter('');
         $progress->setBarCharacter('▓');
         // dark shade character \u2593
     }
     $progress->start();
     // Start from $max and decrement $current by $size until we reach $min
     $current = $max;
     while ($current >= $min) {
         $start = max($min, $current + 1 - $size);
         $end = max($min, $current);
         $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', str_replace('text_reparser.', '', $name), $start, $end));
         $reparser->reparse_range($start, $end);
         $current = $start - 1;
         $progress->setProgress($max + 1 - $start);
     }
     $progress->finish();
     $this->io->newLine(2);
 }
 /**
  * Execute the command.
  *
  * @param  InputInterface $input
  * @param  OutputInterface $output
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io = new SymfonyStyle($input, $output);
     $this->verifyApplicationDoesntExist($this->directory = $input->getArgument('name') ? getcwd() . '/' . $input->getArgument('name') : getcwd());
     $this->checker = new EnvironmentChecker($this->directory);
     $this->writer = new FileWriter($this->io, $this->directory);
     $this->configureDatabase()->configureAdmin()->configureHostName()->configureLocale()->configureTimeZone();
     if (!$this->confirmConfiguration()) {
         return;
     }
     $this->io->title('Installing project...');
     $composer = $this->findComposer();
     $this->runCommands($composer . ' create-project silverstripe/installer ' . $this->directory, $output);
     $this->io->newLine();
     $this->io->title('Writing configuration');
     $this->writer->writeEnvironmentFile($this->config);
     $this->writer->writeConfigFile($this->config);
     $this->runCommands(['cd ' . $this->directory, 'php framework/cli-script.php dev/build'], $output, true);
     // suppress database build messages
     $this->io->title('Writing configuration');
     $this->removeInstallationFiles();
     $this->writer->writeTestFiles();
     $this->io->success(['Project ready!', 'Test your website by entering : cd ' . $input->getArgument('name') . ' && vendor/bin/phpunit mysite', 'and visit your website on ' . $this->config['hostname']['hostname']]);
 }
Esempio n. 24
0
 private function installAssets(SymfonyStyle $io)
 {
     $io->section("Installing assets...");
     $input = $this->getEnvsInput('prod');
     $commands = array('assets:install', 'assetic:dump');
     $io->progressStart(count($commands));
     foreach ($commands as $command) {
         $cmdOutput = new BufferedOutput();
         $returnCode = $this->getApplication()->find($command)->run($input, $cmdOutput);
         if ($returnCode !== 0) {
             $io->newLine(2);
             $io->error("{$command} failed. Run it separately to find out why.");
             return;
         }
         $io->progressAdvance();
     }
     $io->progressFinish();
 }
Esempio n. 25
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $input->isInteractive() ? $io->title('Symfony Password Encoder Utility') : $io->newLine();
     $password = $input->getArgument('password');
     $userClass = $input->getArgument('user-class');
     $emptySalt = $input->getOption('empty-salt');
     $encoder = $this->getContainer()->get('security.encoder_factory')->getEncoder($userClass);
     $bcryptWithoutEmptySalt = !$emptySalt && $encoder instanceof BCryptPasswordEncoder;
     if ($bcryptWithoutEmptySalt) {
         $emptySalt = true;
     }
     if (!$password) {
         if (!$input->isInteractive()) {
             $io->error('The password must not be empty.');
             return 1;
         }
         $passwordQuestion = $this->createPasswordQuestion();
         $password = $io->askQuestion($passwordQuestion);
     }
     $salt = null;
     if ($input->isInteractive() && !$emptySalt) {
         $emptySalt = true;
         $io->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. ' . PHP_EOL . 'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.');
         if ($io->confirm('Confirm salt generation ?')) {
             $salt = $this->generateSalt();
             $emptySalt = false;
         }
     } elseif (!$emptySalt) {
         $salt = $this->generateSalt();
     }
     $encodedPassword = $encoder->encodePassword($password, $salt);
     $rows = array(array('Encoder used', get_class($encoder)), array('Encoded password', $encodedPassword));
     if (!$emptySalt) {
         $rows[] = array('Generated salt', $salt);
     }
     $io->table(array('Key', 'Value'), $rows);
     if (!$emptySalt) {
         $io->note(sprintf('Make sure that your salt storage field fits the salt length: %s chars', strlen($salt)));
     } elseif ($bcryptWithoutEmptySalt) {
         $io->note('Bcrypt encoder used: the encoder generated its own built-in salt.');
     }
     $io->success('Password encoding succeeded');
 }
Esempio n. 26
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return int|null|void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->dispatcher = $this->getContainer()->get('event_dispatcher');
     $this->output = new SymfonyStyle($input, $output);
     $this->dispatcher->dispatch(BotEvent::START, BotEvent::create('START'));
     $this->output->title((new \DateTime())->format('Y-m-d H:i:s') . 'Starting ' . $this->getContainer()->getParameter('name'));
     $this->updateModules();
     $this->fillIgnoredRepository();
     /** @var Discord $discord */
     $discord = $this->getContainer()->get('discord');
     $this->dispatcher->dispatch(BotEvent::PREPARE, BotEvent::create('PREPARE'));
     $discord->on('error', [$this, 'logError']);
     $servers = 0;
     $progress = null;
     $this->output->note('Loading up servers. Please wait.');
     $progress = $this->output->createProgressBar($this->getTotalServers());
     $discord->on('available', function () use(&$servers, $progress) {
         $servers++;
         $this->updateServerFile($servers);
         if ($progress !== null) {
             $progress->advance();
         }
     });
     $discord->on('ready', function () use($discord, &$servers, $progress) {
         $this->dispatcher->dispatch(BotEvent::READY_START, BotEvent::create('READY_START'));
         $this->updateServerFile($servers);
         if ($progress !== null) {
             $progress->finish();
             $this->output->newLine(2);
         }
         $this->getContainer()->get('listener.discord')->listen();
         $this->output->success('Bot is ready!');
         $this->createServerManagers();
         $status = $this->getContainer()->getParameter('status');
         $this->output->note('Setting status to: ' . $status['name']);
         $discord->updatePresence($discord->factory(Game::class, $status), false);
         $this->dispatcher->dispatch(BotEvent::READY_FINISH, BotEvent::create('READY_FINISH'));
     });
     try {
         $discord->run();
     } catch (ContextErrorException $e) {
     }
 }
 private function normalizePeriods()
 {
     $this->io->newLine();
     $this->io->text('normalizing periods');
     $this->getContainer()->getParameter('locale');
     $this->io->progressStart();
     $periods = $this->em->getRepository('OjsJournalBundle:Period')->findAll();
     foreach ($periods as $period) {
         $getTranslation = $this->em->getRepository('OjsJournalBundle:PeriodTranslation')->findOneBy(['translatable' => $period, 'locale' => $this->locale]);
         if (!$getTranslation) {
             $this->io->progressAdvance();
             $newPeriodTranslation = new PeriodTranslation();
             $newPeriodTranslation->setTranslatable($period);
             $newPeriodTranslation->setLocale($this->locale);
             $newPeriodTranslation->setPeriod('-');
             $this->em->persist($newPeriodTranslation);
         }
     }
     $this->em->flush();
     $this->io->newLine();
 }
 protected function execute(Input\InputInterface $input, Output\OutputInterface $output)
 {
     $this->stopwatch->start('changelog');
     $io = new SymfonyStyle($input, $output);
     $io->title('Localheinz GitHub Changelog');
     $authToken = $input->getOption('auth-token');
     if (null !== $authToken) {
         $this->client->authenticate($authToken, Client::AUTH_HTTP_TOKEN);
     }
     $owner = $input->getArgument('owner');
     $repository = $input->getArgument('repository');
     $startReference = $input->getArgument('start-reference');
     $endReference = $input->getArgument('end-reference');
     $range = $this->range($startReference, $endReference);
     $io->section(sprintf('Pull Requests for %s/%s %s', $owner, $repository, $range));
     try {
         $range = $this->pullRequestRepository->items($owner, $repository, $startReference, $endReference);
     } catch (\Exception $exception) {
         $io->error(sprintf('An error occurred: %s', $exception->getMessage()));
         return 1;
     }
     $pullRequests = $range->pullRequests();
     if (!count($pullRequests)) {
         $io->warning('Could not find any pull requests');
     } else {
         $template = $input->getOption('template');
         $pullRequests = array_reverse($pullRequests);
         array_walk($pullRequests, function (Resource\PullRequestInterface $pullRequest) use($output, $template) {
             $message = str_replace(['%title%', '%id%'], [$pullRequest->title(), $pullRequest->id()], $template);
             $output->writeln($message);
         });
         $io->newLine();
         $io->success(sprintf('Found %s pull request%s.', count($pullRequests), count($pullRequests) === 1 ? '' : 's', $range));
     }
     $event = $this->stopwatch->stop('changelog');
     $io->writeln($this->formatStopwatchEvent($event));
     return 0;
 }
Esempio n. 29
0
 /**
  * Reparse all text handled by given reparser within given range
  *
  * @param string $name Reparser service name
  */
 protected function reparse($name)
 {
     $reparser = $this->reparsers[$name];
     $this->resume_data = $this->reparser_manager->get_resume_data($name);
     if ($this->input->getOption('dry-run')) {
         $reparser->disable_save();
     } else {
         $reparser->enable_save();
     }
     // Start at range-max if specified or at the highest ID otherwise
     $max = $this->get_option('range-max');
     $min = $this->get_option('range-min');
     $size = $this->get_option('range-size');
     // range-max has no default value, it must be computed for each reparser
     if ($max === null) {
         $max = $reparser->get_max_id();
     }
     if ($max < $min) {
         return;
     }
     $this->io->section($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', $reparser->get_name(), $min, $max));
     $progress = $this->create_progress_bar($max, $this->io, $this->output, true);
     $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING_START', $reparser->get_name()));
     $progress->start();
     // Start from $max and decrement $current by $size until we reach $min
     $current = $max;
     while ($current >= $min) {
         $start = max($min, $current + 1 - $size);
         $end = max($min, $current);
         $progress->setMessage($this->user->lang('CLI_REPARSER_REPARSE_REPARSING', $reparser->get_name(), $start, $end));
         $reparser->reparse_range($start, $end);
         $current = $start - 1;
         $progress->setProgress($max + 1 - $start);
         $this->reparser_manager->update_resume_data($name, $min, $current, $size, !$this->input->getOption('dry-run'));
     }
     $progress->finish();
     $this->io->newLine(2);
 }
Esempio n. 30
-1
    /**
     * @param InputInterface $input
     * @param OutputInterface $output
     *
     * @return void
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->io->title($this->getDescription());
        $totalAuthorCount = $this->getAuthorCount();
        $this->io->progressStart($totalAuthorCount);
        $rsm = new ResultSetMapping();
        for ($count = 0; $count <= $totalAuthorCount; $count += self::STEP) {
            $sql = <<<SQL
        UPDATE author
        SET user_id = users.id
        FROM users
        WHERE author.email = users.email
        AND author.id > ?
        and author.id < ?
        and author.user_id is null
SQL;
            $query = $this->em->createNativeQuery($sql, $rsm);
            $query->setParameter(1, $count);
            $query->setParameter(2, $count + self::STEP);
            $query->getResult();
            if (self::STEP > $totalAuthorCount) {
                $this->io->progressFinish();
            } else {
                $this->io->progressAdvance(self::STEP);
            }
        }
        $this->io->newLine(2);
        $this->io->success('All process finished');
    }