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(); } }
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)); }
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(); } }
protected function execute(InputInterface $input, OutputInterface $output) { // throw new \Exception('boo'); $directory = realpath($input->getArgument('directory')); $directoryOutput = $input->getArgument('outputdirectory'); /* @var $logger Psr\Log\LoggerInterface */ $this->logger = $this->getContainer()->get('logger'); $io = new SymfonyStyle($input, $output); $io->title('DDD Model Generation'); $clean = $input->hasOption('clean'); if ($clean) { $io->section('Clean output directoty'); $fs = new \Symfony\Component\Filesystem\Filesystem(); try { $fs->remove($directoryOutput); } catch (IOExceptionInterface $e) { $io->error($e->getMessage()); } $io->text('clean of ' . $directoryOutput . ' completed'); } if (is_dir($directory)) { $finder = new Finder(); $finder->search($directory); foreach ($finder->getFindedFiles() as $file) { if (pathinfo($file, PATHINFO_FILENAME) == 'model.yml') { $io->text('Analizzo model.yml in ' . pathinfo($file, PATHINFO_DIRNAME)); $dddGenerator = new DDDGenerator(); $dddGenerator->setLogger($this->logger); $dddGenerator->analyze($file); $dddGenerator->generate($directoryOutput); } } $io->section('Php-Cs-Fixer on generated files'); $fixer = new \Symfony\CS\Console\Command\FixCommand(); $input = new ArrayInput(['path' => $directoryOutput, '--level' => 'psr2', '--fixers' => 'eof_ending,strict_param,short_array_syntax,trailing_spaces,indentation,line_after_namespace,php_closing_tag']); $output = new BufferedOutput(); $fixer->run($input, $output); $content = $output->fetch(); $io->text($content); if (count($this->errors) == 0) { $io->success('Completed generation'); } else { $io->error($this->errors); } } else { $io->caution('Directory ' . $directory . ' not valid'); } // PER I WARNING RECUPERABILI //$io->note('Generate Class'); }
/** * @param EventDetail $eventOption */ private function startMailEventSync(EventDetail $eventOption) { $this->io->section(sprintf('Started event sync for -> %s -> %s', $eventOption->getName(), $eventOption->getGroup())); foreach ($this->langs as $lang) { if ($eventOption->getGroup() == 'journal') { if (!$this->checkMailTemplateExists($eventOption, $lang, null, true, false)) { $this->createMailTemplateSkeleton($eventOption, $lang, null, true, false); } foreach ($this->allJournals as $journal) { if (!$this->checkMailTemplateExists($eventOption, $lang, $journal, false, true)) { $this->createMailTemplateSkeleton($eventOption, $lang, $journal, false, true, false); } } } else { if ($eventOption->getGroup() == 'admin') { if (!$this->checkMailTemplateExists($eventOption, $lang, null, false, false)) { $this->createMailTemplateSkeleton($eventOption, $lang, null, false, false); } } } if ($this->syncDescriptions) { $this->syncEventDescription($eventOption, $lang); } $this->em->flush(); } }
/** * @param SymfonyStyle|null $io */ public function updateCode(SymfonyStyle $io = null) { $io->title('CampaignChain Data Update'); if (empty($this->versions)) { $io->warning('No code updater Service found, maybe you didn\'t enable a bundle?'); return; } $io->comment('The following data versions will be updated'); $migratedVersions = array_map(function (DataUpdateVersion $version) { return $version->getVersion(); }, $this->em->getRepository('CampaignChainUpdateBundle:DataUpdateVersion')->findAll()); $updated = false; foreach ($this->versions as $version => $class) { if (in_array($version, $migratedVersions)) { continue; } $io->section('Version ' . $class->getVersion()); $io->listing($class->getDescription()); $io->text('Begin data update'); $result = $class->execute($io); if ($result) { $dbVersion = new DataUpdateVersion(); $dbVersion->setVersion($version); $this->em->persist($dbVersion); $this->em->flush(); $io->text('Data update finished'); } $updated = true; } if (!$updated) { $io->success('All data is up to date.'); } else { $io->success('Every data version has been updated.'); } }
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(); } } }
/** * 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); }
/** * 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; }
/** * @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; }
/** * @return int */ protected function listAttendants() { $attendants = array_map(function (CacheAttendantInterface $a) { return ClassInfo::getClassNameByInstance($a); }, $this->getCacheAttendants([], true)); $header = ['Cache Registrar Name', 'Enabled', 'Initialized']; if ($this->output->isVerbose()) { $header = array_merge($header, ['TTL', 'Key Prefix', 'Hash Algo', 'Item Count']); } $rows = []; foreach ($attendants as $i => $name) { $instance = $this->getCacheAttendants([$name])[0]; $rows[$i] = [$name, $instance->isEnabled() ? 'Yes' : '<fg=white>No</>', $instance->isInitialized() ? 'Yes' : '<fg=white>No</>']; if (!$this->output->isVerbose()) { continue; } $ttl = $this->getAttendantTtl($instance); $gen = $this->getAttendantKeyGenerator($instance); try { $num = count($instance->listKeys()); } catch (\Exception $e) { $num = '<fg=white>n/a</>'; } $rows[$i] = array_merge($rows[$i], [$ttl === 0 ? '<fg=white>0</>' : $ttl, $gen->getPrefix(), $gen->getAlgorithm(), $num]); } $this->io->section('Cache Registry Attendant Listing'); $this->io->table($header, $rows); return 0; }
protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->title('Payroll sending for ' . $input->getArgument('month')); try { $io->section('Checking server'); $io->success($this->checkServer()); $io->section('Processing Employee list'); $this->bus->execute(new DistributePayroll(new PayrollMonth($input->getArgument('month'), $input->getArgument('year')), $input->getArgument('paths'))); $io->success('Task ended.'); } catch (\Milhojas\Infrastructure\Persistence\Management\Exceptions\PayrollRepositoryDoesNotExist $e) { $io->warning(array(sprintf($e->getMessage()), 'Please, review config/services/management.yml parameter: payroll.dataPath', 'Use a path to a valid folder containing payroll files or payroll zip archives.')); } catch (\Milhojas\Infrastructure\Persistence\Management\Exceptions\PayrollRepositoryForMonthDoesNotExist $e) { $io->warning(array($e->getMessage(), 'Please, add the needed folder or zip archives for month data.', 'Use a path to a valid folder containing payroll files.')); } catch (\RuntimeException $e) { $io->error(array($e->getMessage(), 'Check Internet connectivity and try again later.')); } }
/** * @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); }
/** * @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); }
public function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->title('OpenCFP'); $io->section('Clearing caches'); $paths = [$this->app->cachePurifierPath(), $this->app->cacheTwigPath()]; array_walk($paths, function ($path) use($io) { passthru(sprintf('rm -rf %s/*', $path)); $io->writeln(sprintf(' * %s', $path)); }); $io->success('Cleared caches.'); }
/** * Displays an information about single aspect * * @param SymfonyStyle $io Input-output style * @param Aspect $aspect Instance of aspect */ private function showAspectInfo(SymfonyStyle $io, Aspect $aspect) { $refAspect = new \ReflectionObject($aspect); $aspectName = $refAspect->getName(); $io->section($aspectName); $io->writeln('Defined in: <info>' . $refAspect->getFileName() . '</info>'); $docComment = $refAspect->getDocComment(); if ($docComment) { $io->writeln($this->getPrettyText($docComment)); } $this->showAspectPointcutsAndAdvisors($io, $aspect); }
/** * 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); }
/** * Executes the command thumbnail:generate. * * Generate a thumbnail for all attachments which need one and don't have it yet. * * @param InputInterface $input The input stream used to get the argument and verboe option. * @param OutputInterface $output The output stream, used for printing verbose-mode and error information. * * @return int 0. */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->section($this->user->lang('CLI_THUMBNAIL_GENERATING')); $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails FROM ' . ATTACHMENTS_TABLE . ' WHERE thumbnail = 0'; $result = $this->db->sql_query($sql); $nb_missing_thumbnails = (int) $this->db->sql_fetchfield('nb_missing_thumbnails'); $this->db->sql_freeresult($result); if ($nb_missing_thumbnails === 0) { $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_GENERATE')); return 0; } $extensions = $this->cache->obtain_attach_extensions(true); $sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype FROM ' . ATTACHMENTS_TABLE . ' WHERE thumbnail = 0'; $result = $this->db->sql_query($sql); if (!function_exists('create_thumbnail')) { require $this->phpbb_root_path . 'includes/functions_posting.' . $this->php_ext; } $progress = $this->create_progress_bar($nb_missing_thumbnails, $io, $output); $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATING')); $progress->start(); $thumbnail_created = array(); while ($row = $this->db->sql_fetchrow($result)) { if (isset($extensions[$row['extension']]['display_cat']) && $extensions[$row['extension']]['display_cat'] == ATTACHMENT_CATEGORY_IMAGE) { $source = $this->phpbb_root_path . 'files/' . $row['physical_filename']; $destination = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename']; if (create_thumbnail($source, $destination, $row['mimetype'])) { $thumbnail_created[] = (int) $row['attach_id']; if (count($thumbnail_created) === 250) { $this->commit_changes($thumbnail_created); $thumbnail_created = array(); } $progress->setMessage($this->user->lang('CLI_THUMBNAIL_GENERATED', $row['real_filename'], $row['physical_filename'])); } else { $progress->setMessage('<info>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</info>'); } } $progress->advance(); } $this->db->sql_freeresult($result); if (!empty($thumbnail_created)) { $this->commit_changes($thumbnail_created); } $progress->finish(); $io->newLine(2); $io->success($this->user->lang('CLI_THUMBNAIL_GENERATING_DONE')); return 0; }
/** * Interesting events. * * Example: User logs in, SQL logs. * * @param string $message * @param array $context * @return null */ public function info($message, array $context = array()) { if (!$this->title) { $this->outputStyle->title($message); $this->title = true; return; } if (strpos($message, '[OK]') !== false) { $this->outputStyle->success($message); } else { $this->outputStyle->section($message); } }
/** * Executes the command to find and update records with FlexForms where the values do not match the datastructures * * @param InputInterface $input * @param OutputInterface $output * * @return void */ protected function execute(InputInterface $input, OutputInterface $output) { // The backend user needs super-powers because datahandler is executed $previouslyAppliedAdminRights = $this->getBackendUser()->user['admin']; $this->getBackendUser()->user['admin'] = 1; $io = new SymfonyStyle($input, $output); $io->title($this->getDescription()); $startingPoint = 0; if ($input->hasOption('pid') && MathUtility::canBeInterpretedAsInteger($input->getOption('pid'))) { $startingPoint = MathUtility::forceIntegerInRange((int) $input->getOption('pid'), 0); } $depth = 1000; if ($input->hasOption('depth') && MathUtility::canBeInterpretedAsInteger($input->getOption('depth'))) { $depth = MathUtility::forceIntegerInRange((int) $input->getOption('depth'), 0); } if ($io->isVerbose()) { $io->section('Searching the database now for records with FlexForms that need to be updated.'); } // Type unsafe comparison and explicit boolean setting on purpose $dryRun = $input->hasOption('dry-run') && $input->getOption('dry-run') != false ? true : false; // Find all records that should be updated $recordsToUpdate = $this->findAllDirtyFlexformsInPage($startingPoint, $depth); if (!$io->isQuiet()) { $io->note('Found ' . count($recordsToUpdate) . ' records with wrong FlexForms information.'); } if (!empty($recordsToUpdate)) { $io->section('Cleanup process starting now.' . ($dryRun ? ' (Not deleting now, just a dry run)' : '')); // Clean up the records now $this->cleanFlexFormRecords($recordsToUpdate, $dryRun, $io); $io->success('All done!'); } else { $io->success('Nothing to do - You\'re all set!'); } // Restore backend user administration rights $this->getBackendUser()->user['admin'] = $previouslyAppliedAdminRights; }
protected function execute(InputInterface $input, OutputInterface $output) { /** @var SlackBot $slackBot */ $slackBot = $this->getContainer()->get('wowapps.slackbot'); $slackBotConfig = $slackBot->getConfig(); $symfonyStyle = new SymfonyStyle($input, $output); echo PHP_EOL; $output->writeln('<bg=blue;options=bold;fg=white> </>'); $output->writeln('<bg=blue;options=bold;fg=white> S L A C K B O T T E S T </>'); $output->writeln('<bg=blue;options=bold;fg=white> </>'); echo PHP_EOL; $symfonyStyle->section('SlackBot general settings'); $symfonyStyle->table(['api url'], [[$slackBotConfig['api_url']]]); $symfonyStyle->table(['default icon'], [[$slackBotConfig['default_icon']]]); $symfonyStyle->table(['default recipient'], [[$slackBotConfig['default_channel']]]); $symfonyStyle->section('SlackBot quote colors'); $symfonyStyle->table(['default', 'info', 'warning', 'success', 'danger'], [[$slackBotConfig['quote_color']['default'], $slackBotConfig['quote_color']['info'], $slackBotConfig['quote_color']['warning'], $slackBotConfig['quote_color']['success'], $slackBotConfig['quote_color']['danger']]]); $symfonyStyle->section('Sending short message...'); if ($this->sendTestMessage($slackBot)) { $symfonyStyle->success('Message sent successfully'); } else { $symfonyStyle->error('Message not sent'); } }
/** * Executes the command thumbnail:delete. * * Deletes all existing thumbnails and updates the database accordingly. * * @param InputInterface $input The input stream used to get the argument and verbose option. * @param OutputInterface $output The output stream, used for printing verbose-mode and error information. * * @return int 0 if all is ok, 1 if a thumbnail couldn't be deleted. */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->section($this->user->lang('CLI_THUMBNAIL_DELETING')); $sql = 'SELECT COUNT(*) AS nb_missing_thumbnails FROM ' . ATTACHMENTS_TABLE . ' WHERE thumbnail = 1'; $result = $this->db->sql_query($sql); $nb_missing_thumbnails = (int) $this->db->sql_fetchfield('nb_missing_thumbnails'); $this->db->sql_freeresult($result); if ($nb_missing_thumbnails === 0) { $io->warning($this->user->lang('CLI_THUMBNAIL_NOTHING_TO_DELETE')); return 0; } $sql = 'SELECT attach_id, physical_filename, extension, real_filename, mimetype FROM ' . ATTACHMENTS_TABLE . ' WHERE thumbnail = 1'; $result = $this->db->sql_query($sql); $progress = $this->create_progress_bar($nb_missing_thumbnails, $io, $output); $progress->setMessage($this->user->lang('CLI_THUMBNAIL_DELETING')); $progress->start(); $thumbnail_deleted = array(); $return = 0; while ($row = $this->db->sql_fetchrow($result)) { $thumbnail_path = $this->phpbb_root_path . 'files/thumb_' . $row['physical_filename']; if (@unlink($thumbnail_path)) { $thumbnail_deleted[] = $row['attach_id']; if (sizeof($thumbnail_deleted) === 250) { $this->commit_changes($thumbnail_deleted); $thumbnail_deleted = array(); } $progress->setMessage($this->user->lang('CLI_THUMBNAIL_DELETED', $row['real_filename'], $row['physical_filename'])); } else { $return = 1; $progress->setMessage('<error>' . $this->user->lang('CLI_THUMBNAIL_SKIPPED', $row['real_filename'], $row['physical_filename']) . '</error>'); } $progress->advance(); } $this->db->sql_freeresult($result); if (!empty($thumbnail_deleted)) { $this->commit_changes($thumbnail_deleted); } $progress->finish(); $io->newLine(2); $io->success($this->user->lang('CLI_THUMBNAIL_DELETING_DONE')); return $return; }
public function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->title('OpenCFP'); $io->section('Creating User'); $user = $this->createUser(['first_name' => $input->getOption('first_name'), 'last_name' => $input->getOption('last_name'), 'password' => $input->getOption('password'), 'email' => $input->getOption('email')]); if (false === $user) { $io->error('User Already Exists!'); return 1; } $io->block('Account was created'); if ($input->getOption('admin')) { $io->block('Promoting to admin.'); $this->promote($user); } $io->success('User Created!'); }
/** * Executes the command user:reclean * * Cleans user names that are unclean. * * @param InputInterface $input The input stream used to get the options * @param OutputInterface $output The output stream, used to print messages * * @return int 0 if all is well, 1 if any errors occurred */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $io->section($this->language->lang('CLI_USER_RECLEAN_START')); $this->processed = 0; $this->progress = $this->create_progress_bar($this->get_count(), $io, $output); $this->progress->setMessage($this->language->lang('CLI_USER_RECLEAN_START')); $this->progress->start(); $stage = 0; while ($stage !== true) { $stage = $this->reclean_usernames($stage); } $this->progress->finish(); $io->newLine(2); $io->success($this->language->lang('CLI_USER_RECLEAN_DONE', $this->processed)); return 0; }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $file = $input->getOption('config') ?: sprintf('%s/pbjc.yml', getcwd()); if (!file_exists($file)) { $io->error(sprintf('File "%s" does not exists.', $file)); return; } $parser = new Parser(); $data = $parser->parse(file_get_contents($file)); if (!is_array($data['namespaces'])) { $data['namespaces'] = [$data['namespaces']]; } $io->title('Generated files for namespaces:'); $io->listing($data['namespaces']); // output callback $callback = function (OutputFile $file) use($io) { $io->text($file->getFile()); if (!is_dir(dirname($file->getFile()))) { mkdir(dirname($file->getFile()), 0777, true); } file_put_contents($file->getFile(), $file->getContents()); }; $languages = []; if (isset($data['languages'])) { $languages = $data['languages']; unset($data['languages']); } $compile = new Compiler(); foreach ($languages as $language => $options) { if ($input->getOption('language') && $input->getOption('language') != $language) { continue; } $options = array_merge($data, $options, ['callback' => $callback]); try { $io->section($language); $compile->run($language, new CompileOptions($options)); $io->success("👍"); //thumbs-up-sign } catch (\Exception $e) { $io->error($e->getMessage()); } } }
/** * Check single backup-configuration. * * @param PluginRegistry $plugins * @param SymfonyStyle $io * @param string $name * @param array $backup * * @return bool */ private function checkBackup(PluginRegistry $plugins, SymfonyStyle $io, $name, array $backup) { $io->section('Backup: ' . $name); if (!$plugins->has($backup['plugin'])) { $io->warning(sprintf('Plugin "%s" not found', $backup['plugin'])); return false; } $optionsResolver = new OptionsResolver(); $plugins->getPlugin($backup['plugin'])->configureOptionsResolver($optionsResolver); try { $parameter = $optionsResolver->resolve($backup['parameter']); } catch (InvalidArgumentException $e) { $io->warning(sprintf('Parameter not valid' . PHP_EOL . PHP_EOL . 'Message: "%s"', $e->getMessage())); return false; } $io->write('Parameter:'); $messages = array_filter(explode("\r\n", Yaml::dump($parameter))); $io->block($messages, null, null, ' '); $io->writeln('OK'); return true; }
/** * 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.'); }
public function execute(InputInterface $input, OutputInterface $output) { /* @var Sentry $sentry */ $sentry = $this->app['sentry']; $email = $input->getArgument('email'); $io = new SymfonyStyle($input, $output); $io->title('OpenCFP'); $io->section(sprintf('Promoting account with email %s to Admin', $email)); try { $user = $sentry->getUserProvider()->findByLogin($email); } catch (UserNotFoundException $e) { $io->error(sprintf('Could not find account with email %s.', $email)); return 1; } if ($user->hasAccess('admin')) { $io->error(sprintf('Account with email %s already is in the Admin group.', $email)); return 1; } $adminGroup = $sentry->getGroupProvider()->findByName('Admin'); $user->addGroup($adminGroup); $io->success(sprintf('Added account with email %s to the Admin group', $email)); }
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; }
/** * 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); }