本文整理汇总了PHP中Drupal\Console\Style\DrupalStyle::info方法的典型用法代码示例。如果您正苦于以下问题:PHP DrupalStyle::info方法的具体用法?PHP DrupalStyle::info怎么用?PHP DrupalStyle::info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Console\Style\DrupalStyle
的用法示例。
在下文中一共展示了DrupalStyle::info方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$yaml = new Parser();
$dumper = new Dumper();
$yaml_file = $input->getArgument('yaml-file');
$yaml_key = $input->getArgument('yaml-key');
try {
$yaml_parsed = $yaml->parse(file_get_contents($yaml_file), true);
} catch (\Exception $e) {
$io->error($this->trans('commands.yaml.merge.messages.error-parsing') . ': ' . $e->getMessage());
return;
}
if (empty($yaml_parsed)) {
$io->info(sprintf($this->trans('commands.yaml.merge.messages.wrong-parse'), $yaml_file));
} else {
$nested_array = $this->getApplication()->getNestedArrayHelper();
$parents = explode(".", $yaml_key);
$yaml_value = $nested_array::getValue($yaml_parsed, $parents, $key_exists);
if (!$key_exists) {
$io->info(sprintf($this->trans('commands.yaml.get.value.messages.invalid-key'), $yaml_key, $yaml_file));
}
$output->writeln($yaml_value);
}
}
示例2: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$yaml = new Parser();
$dumper = new Dumper();
$yaml_file = $input->getArgument('yaml-file');
$yaml_key = $input->getArgument('yaml-key');
$yaml_new_key = $input->getArgument('yaml-new-key');
try {
$yaml_parsed = $yaml->parse(file_get_contents($yaml_file));
} catch (\Exception $e) {
$io->error($this->trans('commands.yaml.merge.messages.error-parsing') . ': ' . $e->getMessage());
return;
}
if (empty($yaml_parsed)) {
$io->info(sprintf($this->trans('commands.yaml.merge.messages.wrong-parse'), $yaml_file));
}
$nested_array = $this->getNestedArrayHelper();
$parents = explode(".", $yaml_key);
$nested_array->replaceKey($yaml_parsed, $parents, $yaml_new_key);
try {
$yaml = $dumper->dump($yaml_parsed, 10);
} catch (\Exception $e) {
$io->error($this->trans('commands.yaml.merge.messages.error-generating') . ': ' . $e->getMessage());
return;
}
try {
file_put_contents($yaml_file, $yaml);
} catch (\Exception $e) {
$io->error($this->trans('commands.yaml.merge.messages.error-writing') . ': ' . $e->getMessage());
return;
}
$io->info(sprintf($this->trans('commands.yaml.update.value.messages.updated'), $yaml_file));
}
示例3: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$application = $this->getApplication();
$manifest = $input->getOption('manifest') ?: 'http://drupalconsole.com/manifest.json';
$currentVersion = $input->getOption('current-version') ?: $application->getVersion();
$major = $input->getOption('major');
if (!extension_loaded('Phar') || !\Phar::running(false)) {
$io->error($this->trans('commands.self-update.messages.not-phar'));
$io->block($this->trans('commands.self-update.messages.instructions'));
return 1;
}
$io->info(sprintf($this->trans('commands.self-update.messages.check'), $currentVersion));
$updater = new Updater(null, false);
$strategy = new ManifestStrategy($currentVersion, $major, $manifest);
$updater->setStrategyObject($strategy);
if (!$updater->hasUpdate()) {
$io->info(sprintf($this->trans('commands.self-update.messages.current-version'), $currentVersion));
return 0;
}
$oldVersion = $updater->getOldVersion();
$newVersion = $updater->getNewVersion();
if (!$io->confirm(sprintf($this->trans('commands.self-update.questions.update'), $oldVersion, $newVersion), true)) {
return 1;
}
$io->comment(sprintf($this->trans('commands.self-update.messages.update'), $newVersion));
$updater->update();
$io->success(sprintf($this->trans('commands.self-update.messages.success'), $oldVersion, $newVersion));
// Errors appear if new classes are instantiated after this stage
// (namely, Symfony's ConsoleTerminateEvent). This suggests PHP
// can't read files properly from the overwritten Phar, or perhaps it's
// because the autoloader's name has changed. We avoid the problem by
// terminating now.
exit;
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$language = $input->getArgument('language');
$tableHeader = [$this->trans('commands.locale.translation.status.messages.project'), $this->trans('commands.locale.translation.status.messages.version'), $this->trans('commands.locale.translation.status.messages.local-age'), $this->trans('commands.locale.translation.status.messages.remote-age'), $this->trans('commands.locale.translation.status.messages.info')];
$languages = locale_translatable_language_list();
$status = locale_translation_get_status();
$this->getModuleHandler()->loadInclude('locale', 'compare.inc');
if (!$languages) {
$io->info($this->trans('commands.locale.translation.status.messages.no-languages'));
return;
} elseif (empty($status)) {
$io->info($this->trans('commands.locale.translation.status.messages.no-translations'));
return;
}
if ($languages) {
$projectsStatus = $this->projectsStatus();
foreach ($projectsStatus as $langcode => $rows) {
$tableRows = [];
if ($language != '' && !($language == $langcode || strtolower($language) == strtolower($languages[$langcode]->getName()))) {
continue;
}
$io->info($languages[$langcode]->getName());
foreach ($rows as $row) {
if ($row[0] == 'drupal') {
$row[0] = $this->trans('commands.common.messages.drupal-core');
}
$tableRows[] = $row;
}
$io->table($tableHeader, $tableRows, 'compact');
}
}
}
示例5: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$yaml = new Parser();
$yaml_left = $input->getArgument('yaml-left');
$yaml_right = $input->getArgument('yaml-right');
$stats = $input->getOption('stats');
$negate = $input->getOption('negate');
$limit = $input->getOption('limit');
$offset = $input->getOption('offset');
if ($negate == 1 || $negate == 'TRUE') {
$negate = true;
} else {
$negate = false;
}
try {
$yamlLeftParsed = $yaml->parse(file_get_contents($yaml_left));
if (empty($yamlLeftParsed)) {
$io->error(sprintf($this->trans('commands.yaml.merge.messages.wrong-parse'), $yaml_left));
}
$yamlRightParsed = $yaml->parse(file_get_contents($yaml_right));
if (empty($yamlRightParsed)) {
$io->error(sprintf($this->trans('commands.yaml.merge.messages.wrong-parse'), $yaml_right));
}
} catch (\Exception $e) {
$io->error($this->trans('commands.yaml.merge.messages.error-parsing') . ': ' . $e->getMessage());
return;
}
$statistics = ['total' => 0, 'equal' => 0, 'diff' => 0];
/* print_r($yamlLeftParsed);
print_r($yamlRightParsed);*/
$diff = $this->nestedArray->arrayDiff($yamlLeftParsed, $yamlRightParsed, $negate, $statistics);
print_r($diff);
if ($stats) {
$io->info(sprintf($this->trans('commands.yaml.diff.messages.total'), $statistics['total']));
$io->info(sprintf($this->trans('commands.yaml.diff.messages.diff'), $statistics['diff']));
$io->info(sprintf($this->trans('commands.yaml.diff.messages.equal'), $statistics['equal']));
return;
}
// FLAT YAML file to display full yaml to be used with command yaml:update:key or yaml:update:value
$diffFlatten = array();
$keyFlatten = '';
$this->nestedArray->yamlFlattenArray($diff, $diffFlatten, $keyFlatten);
if ($limit !== null) {
if (!$offset) {
$offset = 0;
}
$diffFlatten = array_slice($diffFlatten, $offset, $limit);
}
$tableHeader = [$this->trans('commands.yaml.diff.messages.key'), $this->trans('commands.yaml.diff.messages.value')];
$tableRows = [];
foreach ($diffFlatten as $yamlKey => $yamlValue) {
$tableRows[] = [$yamlKey, $yamlValue];
print $yamlKey . "\n";
print $yamlValue . "\n";
}
$io->table($tableHeader, $tableRows, 'compact');
}
示例6: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$httpClient = $this->getHttpClientHelper();
$siteName = $input->getArgument('site-name');
$version = $input->getArgument('version');
if ($version) {
$releaseSelected = $version;
} else {
// Getting Module page header and parse to get module Node
$io->info(sprintf($this->trans('commands.site.new.messages.getting-releases')));
// Page for Drupal releases filter by Drupal 8
$projectReleaseSelected = 'https://www.drupal.org/node/3060/release?api_version%5B%5D=7234';
// Parse release module page to get Drupal 8 releases
try {
$html = $httpClient->getHtml($projectReleaseSelected);
} catch (\Exception $e) {
$io->error($e->getMessage());
return;
}
$crawler = new Crawler($html);
$releases = [];
foreach ($crawler->filter('span.file a') as $element) {
if (strpos($element->nodeValue, ".tar.gz") > 0) {
$releaseName = str_replace('.tar.gz', '', str_replace('drupal-', '', $element->nodeValue));
$releases[$releaseName] = $element->nodeValue;
}
}
if (empty($releases)) {
$io->error($this->trans('commands.site.new.messages.no-releases'));
return;
}
$releaseSelected = $io->choice($this->trans('commands.site.new.messages.release'), array_keys($releases));
}
$releaseFilePath = 'http://ftp.drupal.org/files/projects/drupal-' . $releaseSelected . '.tar.gz';
// Destination file to download the release
$destination = tempnam(sys_get_temp_dir(), 'drupal.') . "tar.gz";
try {
// Start the process to download the zip file of release and copy in contrib folter
$io->info(sprintf($this->trans('commands.site.new.messages.downloading'), $releaseSelected));
$httpClient->downloadFile($releaseFilePath, $destination);
$io->info(sprintf($this->trans('commands.site.new.messages.extracting'), $releaseSelected));
$zippy = Zippy::load();
$archive = $zippy->open($destination);
$archive->extract('./');
try {
$filesyStem = new Filesystem();
$filesyStem->rename('./drupal-' . $releaseSelected, './' . $siteName);
} catch (IOExceptionInterface $e) {
$io->error(sprintf($this->trans('commands.site.new.messages.error-copying'), $e->getPath()));
}
$io->success(sprintf($this->trans('commands.site.new.messages.downloaded'), $releaseSelected, $siteName));
} catch (\Exception $e) {
$io->error($e->getMessage());
return false;
}
return true;
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$this->getDrupalHelper()->loadLegacyFile('/core/modules/system/system.module');
$extension_config = $this->getConfigFactory()->getEditable('core.extension');
$moduleInstaller = $this->getModuleInstaller();
// Get info about modules available
$module_data = system_rebuild_module_data();
$module = $input->getArgument('module');
$modules = array_filter(array_map('trim', explode(',', $module)));
$module_list = array_combine($modules, $modules);
// Determine if some module request is missing
if ($missing_modules = array_diff_key($module_list, $module_data)) {
$io->error(sprintf($this->trans('commands.module.uninstall.messages.missing'), implode(', ', $modules), implode(', ', $missing_modules)));
return true;
}
// Only process currently installed modules.
$installed_modules = $extension_config->get('module') ?: array();
if (!($module_list = array_intersect_key($module_list, $installed_modules))) {
$io->info($this->trans('commands.module.uninstall.messages.nothing'));
return true;
}
$force = $input->getOption('force');
if (!$force) {
// Calculate $dependents
$dependents = array();
while (list($module) = each($module_list)) {
foreach (array_keys($module_data[$module]->required_by) as $dependent) {
// Skip already uninstalled modules.
if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent != $profile) {
$dependents[] = $dependent;
}
}
}
// Error if there are missing dependencies
if (!empty($dependents)) {
$io->error(sprintf($this->trans('commands.module.uninstall.messages.dependents'), implode(', ', $modules), implode(', ', $dependents)));
return true;
}
}
// Installing modules
try {
// Uninstall the modules.
$moduleInstaller->uninstall($module_list);
$io->info(sprintf($this->trans('commands.module.uninstall.messages.success'), implode(', ', $modules)));
} catch (\Exception $e) {
$io->error($e->getMessage());
return;
}
// Run cache rebuild to see changes in Web UI
$this->getChain()->addCommand('cache:rebuild', ['cache' => 'discovery']);
}
示例8: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$this->getDrupalHelper()->loadLegacyFile('/core/includes/install.inc');
$this->getDrupalHelper()->loadLegacyFile('/core/includes/update.inc');
$module = $input->getArgument('module');
$update_n = $input->getArgument('update-n');
$module_handler = $this->getModuleHandler();
drupal_load_updates();
update_fix_compatibility();
$updates = update_get_update_list();
if ($module != 'all') {
if (!isset($updates[$module])) {
$io->error(sprintf($this->trans('commands.update.execute.messages.no-module-updates'), $module));
return;
} else {
// filter to execute only a specific module updates
$updates = [$module => $updates[$module]];
if ($update_n && !isset($updates[$module]['pending'][$update_n])) {
$io->info(sprintf($this->trans('commands.update.execute.messages.module-update-function-not-found'), $module, $update_n));
}
}
}
$io->info($this->trans('commands.site.maintenance.description'));
$state = $this->getService('state');
$state->set('system.maintenance_mode', true);
foreach ($updates as $module_name => $module_updates) {
foreach ($module_updates['pending'] as $update_number => $update) {
if ($module != 'all' && $update_n !== null && $update_n != $update_number) {
continue;
}
//Executing all pending updates
if ($update_n > $module_updates['start']) {
$io->info($this->trans('commands.update.execute.messages.executing-required-previous-updates'));
}
for ($update_index = $module_updates['start']; $update_index <= $update_number; $update_index++) {
$io->info(sprintf($this->trans('commands.update.execute.messages.executing-update'), $update_index, $module_name));
try {
$module_handler->invoke($module_name, 'update_' . $update_index);
} catch (\Exception $e) {
watchdog_exception('update', $e);
$io->error($e->getMessage());
}
//Update module schema version
drupal_set_installed_schema_version($module_name, $update_index);
}
}
}
$state->set('system.maintenance_mode', false);
$io->info($this->trans('commands.site.maintenance.messages.maintenance-off'));
$this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
}
示例9: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$this->get('site')->loadLegacyFile('/core/includes/update.inc');
$this->get('site')->loadLegacyFile('/core/includes/install.inc');
$updateRegistry = $this->getDrupalService('update.post_update_registry');
drupal_load_updates();
update_fix_compatibility();
$updates = update_get_update_list();
$postUpdates = $updateRegistry->getPendingUpdateInformation();
$requirements = update_check_requirements();
$severity = drupal_requirements_severity($requirements);
$io->newLine();
if ($severity == REQUIREMENT_ERROR || $severity == REQUIREMENT_WARNING) {
$io->info($this->trans('commands.update.debug.messages.requirements-error'));
$tableHeader = [$this->trans('commands.update.debug.messages.severity'), $this->trans('commands.update.debug.messages.title'), $this->trans('commands.update.debug.messages.value'), $this->trans('commands.update.debug.messages.description')];
$tableRows = [];
foreach ($requirements as $requirement) {
if (isset($requirement['minimum schema']) & in_array($requirement['minimum schema'], array(REQUIREMENT_ERROR, REQUIREMENT_WARNING))) {
$tableRows[] = [$requirement['severity'], $requirement['title'], $requirement['value'], $requirement['description']];
}
}
$io->table($tableHeader, $tableRows);
return;
}
if (empty($updates)) {
$io->info($this->trans('commands.update.debug.messages.no-updates'));
return;
}
$tableHeader = [$this->trans('commands.update.debug.messages.module'), $this->trans('commands.update.debug.messages.update-n'), $this->trans('commands.update.debug.messages.description')];
$io->info($this->trans('commands.update.debug.messages.module-list'));
$tableRows = [];
foreach ($updates as $module => $module_updates) {
foreach ($module_updates['pending'] as $update_n => $update) {
list(, $description) = explode($update_n . " - ", $update);
$tableRows[] = [$module, $update_n, trim($description)];
}
}
$io->table($tableHeader, $tableRows);
$tableHeader = [$this->trans('commands.update.debug.messages.module'), $this->trans('commands.update.debug.messages.post-update'), $this->trans('commands.update.debug.messages.description')];
$io->info($this->trans('commands.update.debug.messages.module-list-post-update'));
$tableRows = [];
foreach ($postUpdates as $module => $module_updates) {
foreach ($module_updates['pending'] as $postUpdateFunction => $message) {
$tableRows[] = [$module, $postUpdateFunction, $message];
}
}
$io->table($tableHeader, $tableRows);
}
示例10: writeSplittedFile
protected function writeSplittedFile($yaml_splitted, $file_output_prefix = '', $file_output_suffix = '', DrupalStyle $io)
{
$dumper = new Dumper();
$io->info($this->trans('commands.yaml.split.messages.generating-split'));
foreach ($yaml_splitted as $key => $value) {
if ($file_output_prefix) {
$key = $file_output_prefix . '.' . $key;
}
if ($file_output_suffix) {
$key .= '.' . $file_output_suffix;
}
$filename = $key . '.yml';
try {
$yaml = $dumper->dump($value, 10);
} catch (\Exception $e) {
$io->error(sprintf('%s: %s', $this->trans('commands.yaml.merge.messages.error-generating'), $e->getMessage()));
return;
}
try {
file_put_contents($filename, $yaml);
} catch (\Exception $e) {
$io->error(sprintf('%s: %s', $this->trans('commands.yaml.merge.messages.error-writing'), $e->getMessage()));
return;
}
$io->success(sprintf($this->trans('commands.yaml.split.messages.split-generated'), $filename));
}
}
示例11: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$environment = $input->getArgument('environment');
$loadedConfigurations = [];
if (in_array($environment, array('dev', 'prod'))) {
$loadedConfigurations = $this->loadConfigurations($environment);
} else {
$io->error($this->trans('commands.site.mode.messages.invalid-env'));
}
$configurationOverrideResult = $this->overrideConfigurations($loadedConfigurations['configurations']);
foreach ($configurationOverrideResult as $configName => $result) {
$io->info($this->trans('commands.site.mode.messages.configuration') . ':', false);
$io->comment($configName);
$tableHeader = [$this->trans('commands.site.mode.messages.configuration-key'), $this->trans('commands.site.mode.messages.original'), $this->trans('commands.site.mode.messages.updated')];
$io->table($tableHeader, $result);
}
$servicesOverrideResult = $this->overrideServices($loadedConfigurations['services'], $io);
if (!empty($servicesOverrideResult)) {
$io->info($this->trans('commands.site.mode.messages.new-services-settings'));
$tableHeaders = [$this->trans('commands.site.mode.messages.service'), $this->trans('commands.site.mode.messages.service-parameter'), $this->trans('commands.site.mode.messages.service-value')];
$io->table($tableHeaders, $servicesOverrideResult);
}
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
}
示例12: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$modules = $input->getArgument('module');
if (!$this->lock->acquire('cron', 900.0)) {
$io->warning($this->trans('commands.cron.execute.messages.lock'));
return 1;
}
if (in_array('all', $modules)) {
$modules = $this->moduleHandler->getImplementations('cron');
}
foreach ($modules as $module) {
if (!$this->moduleHandler->implementsHook($module, 'cron')) {
$io->warning(sprintf($this->trans('commands.cron.execute.messages.module-invalid'), $module));
continue;
}
try {
$io->info(sprintf($this->trans('commands.cron.execute.messages.executing-cron'), $module));
$this->moduleHandler->invoke($module, 'cron');
} catch (\Exception $e) {
watchdog_exception('cron', $e);
$io->error($e->getMessage());
}
}
$this->state->set('system.cron_last', REQUEST_TIME);
$this->lock->release('cron');
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
$io->success($this->trans('commands.cron.execute.messages.success'));
return 0;
}
示例13: themeDetail
protected function themeDetail(DrupalStyle $io, $themeId)
{
$theme = null;
$themes = $this->getThemeHandler()->rebuildThemeData();
if (isset($themes[$themeId])) {
$theme = $themes[$themeId];
} else {
foreach ($themes as $themeAvailableId => $themeAvailable) {
if ($themeAvailable->info['name'] == $themeId) {
$themeId = $themeAvailableId;
$theme = $themeAvailable;
break;
}
}
}
if ($theme) {
$theme = $themes[$themeId];
$status = $this->getThemeStatus($themeId);
$io->info($theme->info['name']);
$io->comment(sprintf('%s : ', $this->trans('commands.theme.debug.messages.status')), false);
$io->writeln($status);
$io->comment(sprintf('%s : ', $this->trans('commands.theme.debug.messages.version')), false);
$io->writeln($theme->info['version']);
$io->comment($this->trans('commands.theme.debug.messages.regions'));
$tableRows = $this->addThemeAttributes($theme->info['regions'], $tableRows);
$io->table([], $tableRows);
} else {
$io->error(sprintf($this->trans('commands.theme.debug.messages.invalid-theme'), $themeId));
}
}
示例14: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$nestedArray = $this->getNestedArrayHelper();
$application = $this->getApplication();
$config = $application->getConfig();
$configApplication = $config->get('application');
unset($configApplication['autowire']);
unset($configApplication['languages']);
unset($configApplication['aliases']);
unset($configApplication['default']);
$configApplicationFlatten = [];
$keyFlatten = '';
$nestedArray->yamlFlattenArray($configApplication, $configApplicationFlatten, $keyFlatten);
$tableHeader = [$this->trans('commands.settings.debug.messages.config-key'), $this->trans('commands.settings.debug.messages.config-value')];
$tableRows = [];
foreach ($configApplicationFlatten as $yamlKey => $yamlValue) {
$tableRows[] = [$yamlKey, $yamlValue];
}
$io->newLine();
$io->info(sprintf('%s :', $this->trans('commands.settings.debug.messages.config-file')), false);
$io->comment(sprintf('%s/.console/config.yml', $config->getUserHomeDir()), true);
$io->newLine();
$io->table($tableHeader, $tableRows, 'compact');
}
示例15: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$module = $input->getArgument('module');
$module_handler = $this->getModuleHandler();
if ($module != 'all') {
$modules = [$module];
} else {
$modules = $module_handler->getImplementations('cron');
}
foreach ($modules as $module) {
if ($module_handler->implementsHook($module, 'cron')) {
$io->info(sprintf($this->trans('commands.cron.execute.messages.executing-cron'), $module));
try {
$module_handler->invoke($module, 'cron');
} catch (\Exception $e) {
watchdog_exception('cron', $e);
$io->error($e->getMessage());
}
} else {
$io->warning(sprintf($this->trans('commands.cron.execute.messages.module-invalid'), $module));
}
}
$this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
}