本文整理汇总了PHP中Symfony\Component\Console\Style\SymfonyStyle::listing方法的典型用法代码示例。如果您正苦于以下问题:PHP SymfonyStyle::listing方法的具体用法?PHP SymfonyStyle::listing怎么用?PHP SymfonyStyle::listing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Style\SymfonyStyle
的用法示例。
在下文中一共展示了SymfonyStyle::listing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
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();
}
}
示例2: printMiddlewares
private function printMiddlewares()
{
if (!$this->configuration->getMiddlewares()) {
return;
}
$this->title('Middlewares');
$this->output->listing($this->configuration->getMiddlewares());
}
示例3: executeLocked
/**
* {@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;
}
示例4: execute
/**
* 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;
}
示例5: 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.');
}
}
示例6: interact
/**
* If the user does not specify the $name parameter, then we will
* prompt for it here.
*
* @hook interact
*
* @param \Symfony\Component\Console\Input\InputInterface $input
* @param \Symfony\Component\Console\Output\OutputInterface $output
*/
public function interact(InputInterface $input, OutputInterface $output)
{
$available_art = $this->availableArt();
$io = new SymfonyStyle($input, $output);
$art_name = $input->getArgument('name');
if (!$art_name) {
$io->title('Available Art');
$io->listing($available_art);
}
}
示例7: summarizeCommits
/**
* Summarize changes since last tag.
*/
protected function summarizeCommits()
{
$last = $this->changelog->getLastRelease();
if (!$last) {
return;
}
$commits = $this->executeQuietly(['git', 'log', $last['name'] . '..HEAD', '--oneline']);
$commits = explode(PHP_EOL, trim($commits));
if (!$commits) {
$this->output->writeln('Commits since <comment>' . $last['name'] . '</comment>:');
$this->output->listing($commits);
}
}
示例8: showLocaleOverview
private function showLocaleOverview()
{
$locale = array_map(function ($locale, $key) {
$enabledMessage = null;
$interfaceMessage = null;
if ($this->defaultEnabledLocale === $key) {
$enabledMessage = ' (default)';
}
if ($this->defaultInterfaceLocale === $key) {
$interfaceMessage = ' (default)';
}
return ['key' => $key, 'locale' => $locale, 'installed' => array_key_exists($key, $this->installedLocale) ? 'Y' : 'N', 'interface' => (array_key_exists($key, $this->interfaceLocale) ? 'Y' : 'N') . $interfaceMessage, 'enabled' => (array_key_exists($key, $this->enabledLocale) ? 'Y' : 'N') . $enabledMessage, 'redirect' => array_key_exists($key, $this->redirectLocale) ? 'Y' : 'N'];
}, $this->getInstallableLocale(), array_keys($this->getInstallableLocale()));
$this->formatter->listing(["key:\t\tThe identifier of the locale", "locale:\tThe name of the locale", "installed:\tPossible locale to use as interface, enabled or redirect locale", "interface:\tLocale that the user in the backend can use for the interface", "enabled:\tLocale that are accessible for visitors", "redirect:\tLocale that people may automatically be redirected to based upon their browser locale"]);
$this->formatter->table(['key', 'locale', 'installed', 'interface', 'enabled', 'redirect'], $locale);
}
示例9: execute
/**
* {@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());
}
}
}
示例10: displayResults
/**
* Displays a security report as plain text.
*
* @param OutputInterface $output
* @param string $lockFilePath The file path to the checked lock file
* @param array $vulnerabilities An array of vulnerabilities
*/
public function displayResults(OutputInterface $output, $lockFilePath, array $vulnerabilities)
{
$output = new SymfonyStyle(new ArrayInput(array()), $output);
$output->title('Symfony Security Check Report');
$output->comment(sprintf('Checked file: <comment>%s</>', realpath($lockFilePath)));
if ($count = count($vulnerabilities)) {
$output->error(sprintf('%d packages have known vulnerabilities.', $count));
} else {
$output->success('No packages have known vulnerabilities.');
}
if (0 !== $count) {
foreach ($vulnerabilities as $dependency => $issues) {
$output->section(sprintf('%s (%s)', $dependency, $issues['version']));
$details = array_map(function ($value) {
return sprintf("<info>%s</>: %s\n %s", $value['cve'] ?: '(no CVE ID)', $value['title'], $value['link']);
}, $issues['advisories']);
$output->listing($details);
}
}
$output->note('This checker can only detect vulnerabilities that are referenced in the SensioLabs security advisories database. Execute this command regularly to check the newly discovered vulnerabilities.');
}
示例11: install
/**
* @param SymfonyStyle|null $io
* @param bool $updateDatabase
*
* @return bool
*
* @throws \Doctrine\DBAL\ConnectionException
* @throws \Exception
*/
public function install(SymfonyStyle $io = null)
{
$this->logger->info('START: MODULES INSTALLER');
$newBundles = $this->bundleConfigService->getNewBundles();
if (empty($newBundles)) {
if ($io) {
$io->success('No new modules found.');
}
$this->logger->info('No new modules found.');
$this->logger->info('END: MODULES INSTALLER');
return false;
}
// Increase timeout limit to run this script.
set_time_limit(240);
$this->kernelService->parseBundlesForKernelConfig($newBundles);
$loggerResult = '';
$this->em->getConnection()->beginTransaction();
$this->registerDistribution();
try {
foreach ($newBundles as $newBundle) {
switch ($newBundle->getType()) {
case 'campaignchain-core':
break;
case 'campaignchain-hook':
// TODO: new vs. update
$this->registerHook($newBundle);
break;
case 'campaignchain-symfony':
$this->registerSymfonyBundle($newBundle);
break;
default:
$this->registerModule($newBundle);
break;
}
$loggerResult .= $newBundle->getName() . ', ';
$this->em->persist($newBundle);
}
$this->em->flush();
// Store the campaign types a campaign can be copied to.
$this->registerCampaignConversions();
// Store the channels related to an activity or Location.
$this->registerChannelRelationships();
// Store the system parameters injected by modules.
$this->registerModuleSystemParams();
// Register any new Bundles in the Symfony kernel.
$this->kernelService->register();
$this->em->getConnection()->commit();
} catch (\Exception $e) {
$this->em->getConnection()->rollBack();
if ($io) {
$io->error('Error at update: ' . $e->getMessage());
}
$this->logger->error('Error: ' . $e->getMessage());
$this->logger->info('END: MODULES INSTALLER');
throw $e;
}
$this->logger->info('Installed/updated modules: ' . rtrim($loggerResult, ', '));
if ($io) {
$io->section('Installed/updated modules:');
$io->listing(explode(', ', rtrim($loggerResult, ', ')));
}
$this->logger->info('END: MODULES INSTALLER');
return true;
}
示例12: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
$twig = $this->getTwigEnvironment();
if (null === $twig) {
$io->error('The Twig environment needs to be set.');
return 1;
}
$types = array('functions', 'filters', 'tests', 'globals');
if ($input->getOption('format') === 'json') {
$data = array();
foreach ($types as $type) {
foreach ($twig->{'get' . ucfirst($type)}() as $name => $entity) {
$data[$type][$name] = $this->getMetadata($type, $entity);
}
}
$data['tests'] = array_keys($data['tests']);
$io->writeln(json_encode($data));
return 0;
}
$filter = $input->getArgument('filter');
foreach ($types as $index => $type) {
$items = array();
foreach ($twig->{'get' . ucfirst($type)}() as $name => $entity) {
if (!$filter || false !== strpos($name, $filter)) {
$items[$name] = $name . $this->getPrettyMetadata($type, $entity);
}
}
if (!$items) {
continue;
}
$io->section(ucfirst($type));
ksort($items);
$io->listing($items);
}
return 0;
}
示例13: function
<?php
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
// Ensure has proper line ending before outputing a text block like with SymfonyStyle::listing() or SymfonyStyle::text()
return function (InputInterface $input, OutputInterface $output) {
$output = new SymfonyStyle($input, $output);
$output->writeln('Lorem ipsum dolor sit amet');
$output->listing(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
// Even using write:
$output->write('Lorem ipsum dolor sit amet');
$output->listing(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
$output->write('Lorem ipsum dolor sit amet');
$output->text(array('Lorem ipsum dolor sit amet', 'consectetur adipiscing elit'));
};
示例14: execute
/**
* Executes the current command.
*
* This method is not abstract because you can use this class
* as a concrete class. In this case, instead of defining the
* execute() method, you set the code to execute by passing
* a Closure to the setCode() method.
*
* @param InputInterface $input An InputInterface instance
* @param OutputInterface $output An OutputInterface instance
*
* @return null|int null or 0 if everything went fine, or an error code
*
* @see setCode()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$styleHelper = new SymfonyStyle($input, $output);
$validatorFactory = new ValidatorFactoryImplementation();
$validators = $validatorFactory->getMessageValidator();
$commitMessage = file_get_contents($input->getArgument(self::ARGUMENT_COMMIT_MESSAGE_FILE));
$commentCharacter = $input->getOption(self::OPTION_COMMENT_CHAR);
$ignorePatterns = $input->getOption(self::OPTION_IGNORE);
foreach ($ignorePatterns as $ignorePattern) {
if (preg_match($ignorePattern, $commitMessage)) {
return 0;
}
}
$safeCommitMessage = preg_replace('/' . preg_quote($commentCharacter) . '.*/', '', $commitMessage);
$message = new MessageImplementation($safeCommitMessage);
$validators->validate($message);
if (count($message->getStatuses()) < 1) {
return 0;
}
$statusList = [];
$isPositive = true;
/** @var Status $status */
foreach ($message->getStatuses() as $status) {
$statusList[] = $status->getMessage() . ' (' . $status->getDetailsUrl() . ')';
$isPositive = $status->isPositive() && $isPositive;
}
if ($isPositive) {
return 0;
}
$styleHelper->error('Incorrectly formatted commit message');
$styleHelper->listing($statusList);
$styleHelper->section('Your Commit Message');
$styleHelper->block($commitMessage);
$styleHelper->warning('A commit has not been created');
return 1;
}
示例15: updateSchema
private function updateSchema(SymfonyStyle $io, $queries)
{
$io->caution("Your database schema needs to be updated. The following queries will be run:");
$io->listing($queries);
if ($this->updateDb === false && $io->confirm("Should we run this queries now?", false) === false) {
return;
}
$cmdOutput = new BufferedOutput();
$command = $this->getApplication()->find('doctrine:schema:update');
$force = new ArrayInput(array('--env' => 'dev', '--dump-sql' => true, '--force' => true));
$command->run($force, $cmdOutput);
$result = $cmdOutput->fetch();
if (strstr($result, 'Database schema updated successfully!') === false) {
$io->error("Couldn't update the schema. Run 'doctrine:schema:update' separately to find out why");
}
$io->success("Database schema updated successfully!");
$this->clearMetadata($io);
}