success() public method

public success ( $message )
Esempio n. 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io = new SymfonyStyle($input, $output);
     $locator = $this->getContainer()->get('campaignchain.core.module.locator');
     $bundles = $locator->getAvailableBundles();
     $selectedBundle = $this->selectBundle($bundles);
     $generateOutput = new BufferedOutput();
     $application = new Application($this->getContainer()->get('kernel'));
     $application->setAutoExit(false);
     $application->run(new ArrayInput(['command' => $this->getDoctrineMigrationsCommand(), '--no-interaction' => true]), $generateOutput);
     preg_match('/Generated new migration class to "(.*)"/', $generateOutput->fetch(), $matches);
     if (count($matches) < 2) {
         //error
         return;
     }
     $pathForMigrationFile = $matches[1];
     preg_match('/Version.*.php/', $pathForMigrationFile, $fileNames);
     if (!count($fileNames)) {
         return;
     }
     $schemaFile = $this->getContainer()->getParameter('kernel.root_dir') . DIRECTORY_SEPARATOR . '..';
     $schemaFile .= DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . $selectedBundle->getName();
     $schemaFile .= str_replace('/', DIRECTORY_SEPARATOR, $this->getContainer()->getParameter('campaignchain_update.bundle.schema_dir'));
     $schemaFile .= DIRECTORY_SEPARATOR . $fileNames[0];
     $fs = new Filesystem();
     $fs->copy($pathForMigrationFile, $schemaFile);
     $fs->remove($pathForMigrationFile);
     $this->io->success('Generation finished. You can find the file here:');
     $this->io->text($schemaFile);
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $mailerServiceName = sprintf('swiftmailer.mailer.%s', $input->getOption('mailer'));
     if (!$this->getContainer()->has($mailerServiceName)) {
         throw new \InvalidArgumentException(sprintf('The mailer "%s" does not exist.', $input->getOption('mailer')));
     }
     switch ($input->getOption('body-source')) {
         case 'file':
             $filename = $input->getOption('body');
             $content = file_get_contents($filename);
             if ($content === false) {
                 throw new \Exception(sprintf('Could not get contents from "%s".', $filename));
             }
             $input->setOption('body', $content);
             break;
         case 'stdin':
             break;
         default:
             throw new \InvalidArgumentException('Body-input option should be "stdin" or "file".');
     }
     $message = $this->createMessage($input);
     $mailer = $this->getContainer()->get($mailerServiceName);
     $sentMessages = $mailer->send($message);
     $this->io->success(sprintf('%s emails were successfully sent.', $sentMessages));
 }
Esempio n. 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $date = new \DateTime($input->getArgument('time'));
     // Get departure/arrival stops
     $departure = $this->cff->getStop($input->getArgument('departure'));
     $arrival = $this->cff->getStop($input->getArgument('arrival'));
     $output->write(sprintf('%s -> %s at %s : ', $departure['value'], $arrival['value'], $date->format('H:s')));
     $times = $this->cff->query($departure, $arrival, $date);
     $times = array_filter($times, function ($value) use($date) {
         return new \DateTime($value['departure']) == $date;
     });
     if ($infos = current($times)['infos']) {
         $output->writeln(sprintf('<comment>%s</comment>', $infos));
         // Create the Transport
         $transport = \Swift_SmtpTransport::newInstance($input->getOption('host'), $input->getOption('port'), $input->getOption('security'))->setUsername($input->getOption('username'))->setPassword($input->getOption('password'));
         $mailer = \Swift_Mailer::newInstance($transport);
         // Create a message
         $message = \Swift_Message::newInstance($infos)->setFrom(array($input->getOption('username') => 'CFFie'))->setTo(array($input->getOption('to')))->setBody(sprintf("%s -> %s at %s\nCFFie", $departure['value'], $arrival['value'], $date->format('H:m')));
         // Send the message
         $result = $mailer->send($message);
         if ($result) {
             $this->output->success($input->getOption('to') . ' alerted !');
         }
     } else {
         $output->writeln('<info>ok</info>');
     }
 }
Esempio n. 4
0
 protected function success($message)
 {
     if ($this->verbose) {
         $this->io->success($message);
     } else {
         $this->output->writeln('[OK]' . $message);
     }
 }
Esempio n. 5
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');
 }
Esempio n. 6
0
 /**
  * {@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)]);
 }
Esempio n. 7
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $model = $input->getArgument('model');
     $seeds = $input->getArgument('seeds');
     $io = new SymfonyStyle($input, $output);
     if (!class_exists($model)) {
         $io->error(array('The model you specified does not exist.', 'You can create a model with the "model:create" command.'));
         return 1;
     }
     $this->dm = $this->createDocumentManager($input->getOption('server'));
     $faker = Faker\Factory::create();
     AnnotationRegistry::registerAutoloadNamespace('Hive\\Annotations', dirname(__FILE__) . '/../../');
     $reflectionClass = new \ReflectionClass($model);
     $properties = $reflectionClass->getProperties(\ReflectionProperty::IS_PUBLIC);
     $reader = new AnnotationReader();
     for ($i = 0; $i < $seeds; $i++) {
         $instance = new $model();
         foreach ($properties as $property) {
             $name = $property->getName();
             $seed = $reader->getPropertyAnnotation($property, 'Hive\\Annotations\\Seed');
             if ($seed !== null) {
                 $fake = $seed->fake;
                 if (class_exists($fake)) {
                     $instance->{$name} = $this->createFakeReference($fake);
                 } else {
                     $instance->{$name} = $faker->{$seed->fake};
                 }
             }
         }
         $this->dm->persist($instance);
     }
     $this->dm->flush();
     $io->success(array("Created {$seeds} seeds for {$model}"));
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->title('Pre-commit delete');
     $git = new GitVersionControl();
     $projectBase = $git->getProjectBase();
     $hookDir = $projectBase . '/.git/hooks';
     if (!$io->confirm('Are you sure to remove Pre-commit hooks on this project?', true)) {
         exit(0);
     }
     $output->writeln('');
     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)) {
         $fs->remove($target);
         $io->success('pre-commit was deleted');
         exit(0);
     }
     $io->error(sprintf('pre-commit file does\'nt exist (%s)', $target));
     exit(1);
 }
Esempio n. 9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $name = str_replace('/', '\\', $input->getArgument('name'));
     $this->migrator->set_output_handler(new log_wrapper_migrator_output_handler($this->language, new console_migrator_output_handler($this->user, $output), $this->phpbb_root_path . 'store/migrations_' . time() . '.log', $this->filesystem));
     $this->cache->purge();
     if (!in_array($name, $this->load_migrations())) {
         $io->error($this->language->lang('MIGRATION_NOT_VALID', $name));
         return 1;
     } else {
         if ($this->migrator->migration_state($name) === false) {
             $io->error($this->language->lang('MIGRATION_NOT_INSTALLED', $name));
             return 1;
         }
     }
     try {
         while ($this->migrator->migration_state($name) !== false) {
             $this->migrator->revert($name);
         }
     } catch (\phpbb\db\migration\exception $e) {
         $io->error($e->getLocalisedMessage($this->user));
         $this->finalise_update();
         return 1;
     }
     $this->finalise_update();
     $io->success($this->language->lang('INLINE_UPDATE_SUCCESSFUL'));
 }
 /**
  * {@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);
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     $this->io->progressStart(count($this->getJournals()));
     $counter = 1;
     foreach ($this->getJournals() as $journal) {
         $this->addTranslation($journal);
         $this->io->progressAdvance(1);
         $counter = $counter + 1;
         if ($counter % 50 == 0) {
             $this->em->flush();
         }
     }
     $this->em->flush();
     $this->io->success('All process finished');
 }
Esempio n. 12
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');
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->comment("Warming up the cache (<info>{$this->cacheDir}</info>)");
     $this->cacheWarmer->warmup($this->cacheDir);
     $io->success('Cache warmed up');
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $fileInput = trim($input->getArgument('file'));
     $pathInfoFile = pathinfo(realpath($fileInput));
     $file = new File('', realpath($fileInput), $pathInfoFile['dirname']);
     $fileCollection = new FileCollection();
     $fileCollection = $fileCollection->append($file);
     $reporter = new Reporter($output, 1);
     $review = new StaticReview($reporter);
     $review->addReview(new PhpCsFixerReview(self::AUTO_ADD_GIT));
     // Review the staged files.
     $review->files($fileCollection);
     // Check if any matching issues were found.
     if ($reporter->hasIssues()) {
         $reporter->displayReport();
     }
     if ($reporter->hasIssueLevel(Issue::LEVEL_ERROR)) {
         $io->error('✘ Please fix the errors above.');
         exit(1);
     } else {
         $io->success('✔ Looking good.');
         exit(0);
     }
 }
 /**
  * @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. 16
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. 17
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $outputFile = $input->getOption('output');
     $this->renderTemplate($input, $outputFile, 'index.php.twig', dirname(__FILE__) . '/../../../templates/scaffold/api/', ['models' => $input->getArgument('models'), 'vendorPath' => $this->getVendorPath($input->getOption('output'))]);
     $io = new SymfonyStyle($input, $output);
     $io->success(["Hive API created in {$outputFile}"]);
 }
Esempio n. 18
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $address = $input->getArgument('address');
     if (strpos($address, ':') === false) {
         $address .= ':' . $input->getOption('port');
     }
     if ($this->isOtherServerProcessRunning($address)) {
         $io->error(sprintf('A process is already listening on http://%s', $address));
         return 1;
     }
     $webDir = $this->app['resources']->getPath('web');
     $router = $webDir . '/index.php';
     $io->success(sprintf('Server running on http://%s', $address));
     $io->comment('Quit the server with CONTROL-C.');
     if (($process = $this->createServerProcess($io, $address, $webDir, $router)) === null) {
         return 1;
     }
     /** @var ProcessHelper $helper */
     $helper = $this->getHelper('process');
     $helper->run($output, $process, null, null, OutputInterface::VERBOSITY_VERBOSE);
     if (!$process->isSuccessful()) {
         $errorMessages = ['Built-in server terminated unexpectedly.'];
         if ($process->isOutputDisabled()) {
             $errorMessages[] = 'Run the command again with -v option for more details.';
         }
         $io->error($errorMessages);
     }
     return $process->getExitCode();
 }
Esempio n. 19
0
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $lockHandler = new LockHandler('app:sync.lock');
     if (!$lockHandler->lock()) {
         $io->warning('Sync process already running');
         return;
     }
     $service = $this->getContainer()->get('app.sync');
     switch ($input->getOption('type')) {
         case 'users':
             $service->syncUsers();
             break;
         case 'groups':
             $service->syncGroups();
             break;
         case 'grouphub':
             $service->syncGrouphubGroups();
             break;
         case 'queue':
             $service->syncGrouphubGroupsFromQueue();
             break;
         default:
             $service->sync();
     }
     $io->success('Done!');
 }
Esempio n. 20
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. 21
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $pools = array();
     $clearers = array();
     $container = $this->getContainer();
     $cacheDir = $container->getParameter('kernel.cache_dir');
     foreach ($input->getArgument('pools') as $id) {
         $pool = $container->get($id);
         if ($pool instanceof CacheItemPoolInterface) {
             $pools[$id] = $pool;
         } elseif ($pool instanceof Psr6CacheClearer) {
             $clearers[$id] = $pool;
         } else {
             throw new \InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
         }
     }
     foreach ($clearers as $id => $clearer) {
         $io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
         $clearer->clear($cacheDir);
     }
     foreach ($pools as $id => $pool) {
         $io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
         $pool->clear();
     }
     $io->success('Cache was successfully cleared.');
 }
Esempio n. 22
0
	/**
	* Executes the command reparser:reparse
	*
	* @param InputInterface $input
	* @param OutputInterface $output
	* @return integer
	*/
	protected function execute(InputInterface $input, OutputInterface $output)
	{
		$this->input = $input;
		$this->output = $output;
		$this->io = new SymfonyStyle($input, $output);

		if (!$this->reparse_lock->acquire())
		{
			throw new runtime_exception('REPARSE_LOCK_ERROR', array(), null, 1);
		}

		$name = $input->getArgument('reparser-name');
		if (isset($name))
		{
			// Allow "post_text" to be an alias for "text_reparser.post_text"
			if (!isset($this->reparsers[$name]))
			{
				$name = 'text_reparser.' . $name;
			}
			$this->reparse($name);
		}
		else
		{
			foreach ($this->reparsers as $name => $service)
			{
				$this->reparse($name);
			}
		}

		$this->io->success($this->user->lang('CLI_REPARSER_REPARSE_SUCCESS'));

		$this->reparse_lock->release();

		return 0;
	}
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $io->comment("Clearing the cache (<info>{$this->cacheDir}</info>)");
     $this->cacheClearer->clear($this->cacheDir);
     $io->success('Cache cleared');
 }
 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io->title($this->getDescription());
     $this->io->progressStart(count($this->getAnnouncements()));
     $counter = 1;
     foreach ($this->getAnnouncements() as $announcement) {
         if (!$this->haveTranslation($announcement['id'])) {
             $this->addTranslation($announcement);
             $this->io->progressAdvance(1);
             $counter = $counter + 1;
             if ($counter % 50 == 0) {
                 $this->em->flush();
             }
         }
     }
     $this->em->flush();
     $this->io->success('All process finished');
 }
Esempio n. 25
0
 /**
  * Executes the command reparser:reparse
  *
  * @param InputInterface $input
  * @param OutputInterface $output
  * @return integer
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->io = new SymfonyStyle($input, $output);
     $name = $input->getArgument('reparser-name');
     if (isset($name)) {
         // Allow "post_text" to be an alias for "text_reparser.post_text"
         if (!isset($this->reparsers[$name])) {
             $name = 'text_reparser.' . $name;
         }
         $this->reparse($input, $output, $name);
     } else {
         foreach ($this->reparsers as $name => $service) {
             $this->reparse($input, $output, $name);
         }
     }
     $this->io->success($this->user->lang('CLI_REPARSER_REPARSE_SUCCESS'));
     return 0;
 }
Esempio n. 26
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.'));
     }
 }
Esempio n. 27
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $dataOption = $input->getOption('data');
     if (file_exists($dataOption)) {
         $dataOption = file_get_contents($dataOption);
     }
     $token = JWT::encode(json_decode($dataOption), $input->getArgument('key'));
     $io->success($token);
 }
Esempio n. 28
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  *
  * @return void
  * @throws Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $updater = new Updater();
     $strategy = $updater->getStrategy();
     if ($strategy instanceof ShaStrategy) {
         $strategy->setPharUrl('http://lucascherifi.github.io/gitaski/gitaski.phar');
         $strategy->setVersionUrl('http://lucascherifi.github.io/gitaski/gitaski.phar.version');
     }
     $result = $updater->update();
     if (!$result) {
         $io = new SymfonyStyle($input, $output);
         $io->success('No update needed.');
         return;
     }
     $new = $updater->getNewVersion();
     $old = $updater->getOldVersion();
     $io->success(sprintf('Updated from %s to %s', $old, $new));
     return;
 }
Esempio n. 29
0
 /**
  *
  * {@inheritdoc}
  *
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $path = $this->getContainer()->getParameter('kernel.root_dir') . '/' . $input->getArgument('path') . "";
     if (!is_dir($path)) {
         $io->error(sprintf('The given document directory "%s" does not exist', $path));
         return 1;
     }
     $io->success(sprintf('Found sources here here: %s', $path));
     $io->comment('Quit the process with CONTROL-C.');
     $files = scandir($path);
     foreach ($files as $file) {
         if (substr($file, -3) == ".js") {
             $jsoutput = \JShrink\Minifier::minify(file_get_contents($path . '/' . $file), array('flaggedComments' => false));
             file_put_contents($path . '/' . $file, $jsoutput);
             $io->success(sprintf('Shrunk: ' . $path . '/' . $file));
         }
     }
     $io->success(sprintf('Success!'));
 }
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');
    }