本文整理汇总了PHP中Symfony\Component\Console\Style\SymfonyStyle::warning方法的典型用法代码示例。如果您正苦于以下问题:PHP SymfonyStyle::warning方法的具体用法?PHP SymfonyStyle::warning怎么用?PHP SymfonyStyle::warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Style\SymfonyStyle
的用法示例。
在下文中一共展示了SymfonyStyle::warning方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @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!');
}
示例2: updateCode
/**
* @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.');
}
}
示例3: execute
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.'));
}
}
示例4: removeInstallationFiles
protected function removeInstallationFiles()
{
$installfiles = array('install.php', 'install-frameworkmissing.html');
foreach ($installfiles as $installfile) {
if (file_exists($this->directory . '/' . $installfile)) {
@unlink($this->directory . '/' . $installfile);
}
file_exists($this->directory . '/' . $installfile) ? $this->io->warning('Could not delete file : ' . $installfile) : $this->io->text('Deleted installation file : ' . $installfile);
}
}
示例5: processMailer
private function processMailer($name, InputInterface $input, OutputInterface $output)
{
if (!$this->getContainer()->has(sprintf('swiftmailer.mailer.%s', $name))) {
throw new \InvalidArgumentException(sprintf('The mailer "%s" does not exist.', $name));
}
$this->io->text(sprintf('<info>[%s]</info> Processing <info>%s</info> mailer spool... ', date('Y-m-d H:i:s'), $name));
if ($this->getContainer()->getParameter(sprintf('swiftmailer.mailer.%s.spool.enabled', $name))) {
$mailer = $this->getContainer()->get(sprintf('swiftmailer.mailer.%s', $name));
$transport = $mailer->getTransport();
if ($transport instanceof \Swift_Transport_LoadBalancedTransport) {
foreach ($transport->getTransports() as $eachTransport) {
$this->recoverSpool($name, $eachTransport, $input, $output);
}
} else {
$this->recoverSpool($name, $transport, $input, $output);
}
} else {
$this->io->warning('There are no emails to send because the spool is disabled.');
}
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$name = $input->getArgument('name');
$timeWindowService = $this->getContainer()->get('mablae_time_window.service');
$result = $timeWindowService->isTimeWindowActive($name);
$io = new SymfonyStyle($input, $output);
if ($result == true) {
$io->success("The time window '{$name}' is active!");
} else {
$io->warning("The time window '{$name}' is NOT active!");
}
}
示例7: checkBackup
/**
* 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;
}
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io = new SymfonyStyle($input, $output);
$this->sort = $input->getOption('sort');
$this->sleepTime = $input->getOption('sleepTime');
if (!$input->hasOption('sleepTime') && $output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL) {
$this->sleepTime = 25;
}
// Transform milliseconds in microseconds for usleep()
$this->sleepTime = $this->sleepTime * 1000;
$this->numberOfCodesToGenerate = $input->getOption('amount');
// The length of each outputted code
$this->codeLength = $input->getOption('length');
// All possible chars. By default, 'A' to 'Z' and '0' to '9'
$this->possibleChars = str_split($input->getOption('characters'));
$baseNumberOfChars = count($this->possibleChars);
$this->possibleChars = array_unique($this->possibleChars);
// If there's an error here, we'll say it later
$maxPossibleNumberOfCombinations = pow(count($this->possibleChars), $this->codeLength);
if ($maxPossibleNumberOfCombinations < $this->numberOfCodesToGenerate) {
$this->io->error(sprintf('Cannot generate %s combinations because there are only %s combinations possible', number_format($this->numberOfCodesToGenerate, 0, '', ' '), number_format($maxPossibleNumberOfCombinations, 0, '', ' ')));
return 1;
} else {
$this->io->block(sprintf('Generating %s combinations.', number_format($this->numberOfCodesToGenerate, 0, '', ' ')), null, 'info');
if ($maxPossibleNumberOfCombinations > $this->numberOfCodesToGenerate) {
$this->io->block(sprintf('Note: If you need you can generate %s more combinations (with a maximum of %s).', number_format($maxPossibleNumberOfCombinations - $this->numberOfCodesToGenerate, 0, '', ' '), number_format($maxPossibleNumberOfCombinations, 0, '', ' ')), null, 'comment');
}
}
$this->io->block('Available characters:');
$this->io->block(implode('', $this->possibleChars), null, 'info');
$codesList = $this->doGenerate();
$outputFile = $input->getOption('output');
if ($outputFile) {
$save = true;
if (file_exists($outputFile)) {
$save = $this->io->confirm(sprintf('File %s exists. Erase it?', $outputFile), false);
}
if ($save) {
$this->io->block(sprintf('Output results to %s', $outputFile), null, 'info');
if (!file_put_contents($outputFile, implode("\n", $codesList))) {
throw new \Exception(sprintf('Could not write to %s...', $outputFile));
}
}
} else {
$this->io->text($codesList);
}
if ($baseNumberOfChars !== count($this->possibleChars)) {
$this->io->warning(sprintf('We detected that there were duplicate characters in "%s", so we removed them.', $input->getOption('characters')));
}
return 0;
}
示例9: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$address = $input->getArgument('address');
// remove an orphaned lock file
if (file_exists($this->getLockFile($address)) && !$this->isServerRunning($address)) {
unlink($this->getLockFile($address));
}
if (file_exists($this->getLockFile($address))) {
$io->success(sprintf('MongoDB server still listening on mongodb://%s', $address));
} else {
$io->warning(sprintf('No server is listening on mongodb://%s', $address));
}
}
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
/** @var FileLoader $fixtureService */
$fixtureService = $this->getContainer()->get('campaignchain.core.fixture');
if ($fixtureService->load($input->getArgument('files'), $input->getOption('doDrop'))) {
// Load schema updates.
$this->loadSchemaUpdateVersions($input, $output);
$io->success('Successfully loaded fixture files.');
} elseif ($fixtureService->getException()) {
$io->warning($fixtureService->getException()->getMessage());
}
return;
}
示例11: execute
/**
* 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;
}
示例12: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$address = $input->getArgument('address');
if (false === strpos($address, ':')) {
$address = $address . ':' . $input->getOption('port');
}
// remove an orphaned lock file
if (file_exists($this->getLockFile($address)) && !$this->isServerRunning($address)) {
unlink($this->getLockFile($address));
}
if (file_exists($this->getLockFile($address))) {
$io->success(sprintf('Web server still listening on http://%s', $address));
} else {
$io->warning(sprintf('No web server is listening on http://%s', $address));
}
}
示例13: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$dbPath = $input->getOption('dbpath');
$fs = new Filesystem();
try {
$fs->mkdir('data/mongodb/');
} catch (IOException $e) {
$io->warning('Could not create "data/mongodb/" directory');
}
// $env = $this->getContainer()->getParameter('kernel.environment');
$env = null;
$address = $input->getArgument('address');
if (false === strpos($address, ':')) {
$address = $address . ':' . $input->getOption('port');
}
if ($this->isOtherServerProcessRunning($address)) {
$io->error(sprintf('A process is already listening on mongodb://%s.', $address));
return 1;
}
/*
if ('prod' === $env) {
$io->error('Running PHP built-in server in production environment is NOT recommended!');
}
*/
$io->success(sprintf('Server running on mongodb://%s', $address));
$io->comment('Quit the server with CONTROL-C.');
if (null === ($builder = $this->createProcessBuilder($io, $input->getArgument('address'), $input->getOption('port'), $dbPath))) {
return 1;
}
//$builder->setWorkingDirectory($documentRoot);
$builder->setTimeout(null);
$process = $builder->getProcess();
if (OutputInterface::VERBOSITY_VERBOSE > $output->getVerbosity()) {
$process->disableOutput();
}
$this->getHelper('process')->run($output, $process, null, null, OutputInterface::VERBOSITY_VERBOSE);
if (!$process->isSuccessful()) {
$errorMessages = array('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();
}
示例14: execute
/**
* {@inheritdoc}
*
* @throws \LogicException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$dispatcher = $this->getEventDispatcher();
$options = array();
if ($event = $input->getArgument('event')) {
if (!$dispatcher->hasListeners($event)) {
$io->warning(sprintf('The event "%s" does not have any registered listeners.', $event));
return;
}
$options = array('event' => $event);
}
$helper = new DescriptorHelper();
$options['format'] = $input->getOption('format');
$options['raw_text'] = $input->getOption('raw');
$options['output'] = $io;
$helper->describe($io, $dispatcher, $options);
}
示例15: writeSymbol
/**
* @param array $symbol
* @param DateTime $lastSunday
*
* @throws Exception
*/
public function writeSymbol($symbol, DateTime $lastSunday)
{
$dates = $this->getDatesFromSymbol($symbol, $lastSunday);
foreach ($dates as $date) {
for ($i = 0; $i < $date['count']; $i++) {
$this->addCommit($date['date']);
echo '.';
}
}
echo "\n";
if ($this->force) {
$this->forcePush();
$this->io->comment('Git local checkout has been created and pushed to the origin repository. You can now view it online.');
} else {
$this->io->warning('Git local checkout has been created but not sent. Use --force to really push it to the github account.');
}
$this->io->success('Done.');
}