本文整理汇总了PHP中Drupal\Console\Style\DrupalStyle::comment方法的典型用法代码示例。如果您正苦于以下问题:PHP DrupalStyle::comment方法的具体用法?PHP DrupalStyle::comment怎么用?PHP DrupalStyle::comment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Console\Style\DrupalStyle
的用法示例。
在下文中一共展示了DrupalStyle::comment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$application = $this->getApplication();
$drupal = $this->getDrupalHelper();
// Provide drupal version if it's installed
$drupalVersion = $this->trans('commands.site.status.messages.not_installed');
if ($drupal->isInstalled()) {
$drupalVersion = sprintf($this->trans('commands.site.status.messages.current_version'), $this->getSite()->getDrupalVersion());
}
$aboutTitle = sprintf('%s (%s) | Supports Drupal (%s) | %s', $this->trans('commands.site.status.messages.console'), $application->getVersion(), $application::DRUPAL_SUPPORTED_VERSION, $drupalVersion);
$io->setDecorated(false);
$io->title($aboutTitle);
$io->setDecorated(true);
$commands = ['init' => [$this->trans('commands.init.description'), 'drupal init --override'], 'quick-start' => [$this->trans('commands.common.messages.quick-start'), 'drupal chain --file=~/.console/chain/quick-start.yml'], 'site-new' => [$this->trans('commands.site.new.description'), sprintf('drupal site:new drupal8.dev %s', $application::DRUPAL_SUPPORTED_VERSION)], 'site-install' => [$this->trans('commands.site.install.description'), sprintf('drupal site:install')], 'links' => [$this->trans('commands.list.description'), 'drupal list']];
foreach ($commands as $command => $commandInfo) {
$io->writeln($commandInfo[0]);
$io->newLine();
$io->comment(sprintf(' %s', $commandInfo[1]));
$io->newLine();
}
$io->setDecorated(false);
$io->section($this->trans('commands.self-update.description'));
$io->setDecorated(true);
$io->comment(' drupal self-update');
$io->newLine();
}
示例2: 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));
}
}
示例3: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$this->get('site')->loadLegacyFile('/core/includes/utility.inc');
$validators = $this->getApplication()->getValidator();
// Get the --cache option and make validation
$cache = $input->getArgument('cache');
$validated_cache = $validators->validateCache($cache);
if (!$validated_cache) {
$io->error(sprintf($this->trans('commands.cache.rebuild.messages.invalid_cache'), $cache));
return;
}
// Start rebuilding cache
$io->newLine();
$io->comment($this->trans('commands.cache.rebuild.messages.rebuild'));
// Get data needed to rebuild cache
$kernelHelper = $this->getApplication()->getKernelHelper();
$classLoader = $kernelHelper->getClassLoader();
$request = $kernelHelper->getRequest();
// Check cache to rebuild
if ($cache === 'all') {
// If cache is all, then clear all caches
drupal_rebuild($classLoader, $request);
} else {
// Else, clear the selected cache
$caches = $validators->getCaches();
$caches[$cache]->deleteAll();
}
$io->success($this->trans('commands.cache.rebuild.messages.completed'));
}
示例4: 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']);
}
示例5: viewDetail
/**
* @param \Drupal\Console\Style\DrupalStyle $io
* @param $view_id
* @return bool
*/
private function viewDetail(DrupalStyle $io, $view_id)
{
$entity_manager = $this->getEntityManager();
$view = $entity_manager->getStorage('view')->load($view_id);
if (empty($view)) {
$io->error(sprintf($this->trans('commands.views.debug.messages.not-found'), $view_id));
return false;
}
$configuration = array();
$configuration[] = [$this->trans('commands.views.debug.messages.view-id'), $view->get('id')];
$configuration[] = [$this->trans('commands.views.debug.messages.view-name'), (string) $view->get('label')];
$configuration[] = [$this->trans('commands.views.debug.messages.tag'), $view->get('tag')];
$configuration[] = [$this->trans('commands.views.debug.messages.status'), $view->status() ? $this->trans('commands.common.status.enabled') : $this->trans('commands.common.status.disabled')];
$configuration[] = [$this->trans('commands.views.debug.messages.description'), $view->get('description')];
$io->comment($view_id);
$io->table([], $configuration);
$tableHeader = [$this->trans('commands.views.debug.messages.display-id'), $this->trans('commands.views.debug.messages.display-name'), $this->trans('commands.views.debug.messages.display-description'), $this->trans('commands.views.debug.messages.display-paths')];
$displays = $this->viewDisplayList($view);
$io->info(sprintf($this->trans('commands.views.debug.messages.display-list'), $view_id));
$tableRows = [];
foreach ($displays as $display_id => $display) {
$tableRows[] = [$display_id, $display['name'], $display['description'], $this->viewDisplayPaths($view, $display_id)];
}
$io->table($tableHeader, $tableRows, 'compact');
}
示例6: 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');
}
示例7: restDetail
private function restDetail(DrupalStyle $io, $resource_id)
{
$config = $this->getRestDrupalConfig();
$resourcePluginManager = $this->getPluginManagerRest();
$plugin = $resourcePluginManager->getInstance(array('id' => $resource_id));
if (empty($plugin)) {
$io->error(sprintf($this->trans('commands.rest.debug.messages.not-found'), $resource_id));
return false;
}
$resource = $plugin->getPluginDefinition();
$configuration = [];
$configuration[] = [$this->trans('commands.rest.debug.messages.id'), $resource['id']];
$configuration[] = [$this->trans('commands.rest.debug.messages.label'), (string) $resource['label']];
$configuration[] = [$this->trans('commands.rest.debug.messages.canonical_url'), $resource['uri_paths']['canonical']];
$configuration[] = [$this->trans('commands.rest.debug.messages.status'), isset($config[$resource['id']]) ? $this->trans('commands.rest.debug.messages.enabled') : $this->trans('commands.rest.debug.messages.disabled')];
$configuration[] = [$this->trans('commands.rest.debug.messages.provider', $resource['provider'])];
$io->comment($resource_id);
$io->newLine();
$io->table([], $configuration, 'compact');
$tableHeader = [$this->trans('commands.rest.debug.messages.rest-state'), $this->trans('commands.rest.debug.messages.supported-formats'), $this->trans('commands.rest.debug.messages.supported_auth')];
$tableRows = [];
foreach ($config[$resource['id']] as $method => $settings) {
$tableRows[] = [$method, implode(', ', $settings['supported_formats']), implode(', ', $settings['supported_auth'])];
}
$io->table($tableHeader, $tableRows);
}
示例8: 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;
}
示例9: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$io->newLine();
$io->comment($this->trans('commands.router.rebuild.messages.rebuilding'));
$this->routerBuilder->rebuild();
$io->success($this->trans('commands.router.rebuild.messages.completed'));
}
示例10: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$image_handler = $this->getService('entity_type.manager')->getStorage('image_style');
$io->newLine();
$io->comment($this->trans('commands.image.styles.debug.messages.styles-list'));
if ($image_handler) {
$this->imageStyleList($io, $image_handler);
}
}
示例11: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$imageStyle = $this->entityTypeManager->getStorage('image_style');
$io->newLine();
$io->comment($this->trans('commands.image.styles.debug.messages.styles-list'));
if ($imageStyle) {
$this->imageStyleList($io, $imageStyle);
}
return 0;
}
示例12: releasesQuestion
/**
* @param \Drupal\Console\Style\DrupalStyle $io
* @param $project
* @return string
*/
public function releasesQuestion(DrupalStyle $io, $project)
{
$commandKey = str_replace(':', '.', $this->getName());
$io->comment(sprintf($this->trans('commands.' . $commandKey . '.messages.getting-releases'), implode(',', array($project))));
$releases = $this->getDrupalApi()->getProjectReleases($project, 15);
if (!$releases) {
$io->error(sprintf($this->trans('commands.' . $commandKey . '.messages.no-releases'), implode(',', array($project))));
return null;
}
$version = $io->choice($this->trans('commands.' . $commandKey . '.messages.select-release'), $releases);
return $version;
}
示例13: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$directory = $input->getArgument('directory');
$version = $input->getArgument('version');
$latest = $input->getOption('latest');
$composer = $input->getOption('composer');
if (!$directory) {
$io->error($this->trans('commands.site.new.messages.missing-directory'));
return 1;
}
if ($composer) {
if (!$version) {
$version = '8.x-dev';
}
$io->newLine();
$io->comment(sprintf($this->trans('commands.site.new.messages.executing'), 'drupal', $version));
$command = sprintf('composer create-project %s:%s %s --no-interaction', 'drupal-composer/drupal-project', $version, $directory);
$io->commentBlock($command);
$shellProcess = $this->get('shell_process');
if ($shellProcess->exec($command)) {
$io->success(sprintf($this->trans('commands.site.new.messages.composer'), $version, $directory));
return 0;
} else {
return 1;
}
}
if (!$version && $latest) {
$version = current($this->getApplication()->getDrupalApi()->getProjectReleases('drupal', 1, true));
}
if (!$version) {
$io->error('Missing version');
return 1;
}
$projectPath = $this->downloadProject($io, 'drupal', $version, 'core');
$downloadPath = sprintf('%sdrupal-%s', $projectPath, $version);
if ($this->isAbsolutePath($directory)) {
$copyPath = $directory;
} else {
$copyPath = sprintf('%s%s', $projectPath, $directory);
}
try {
$fileSystem = new Filesystem();
$fileSystem->rename($downloadPath, $copyPath);
} catch (IOExceptionInterface $e) {
$io->commentBlock(sprintf($this->trans('commands.site.new.messages.downloaded'), $version, $downloadPath));
$io->error(sprintf($this->trans('commands.site.new.messages.error-copying'), $e->getPath()));
return 1;
}
$io->success(sprintf($this->trans('commands.site.new.messages.downloaded'), $version, $copyPath));
return 0;
}
示例14: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$settingKeys = array_keys($this->settings->getAll());
$io->newLine();
$io->info($this->trans('commands.config.settings.debug.messages.current'));
$io->newLine();
foreach ($settingKeys as $settingKey) {
$io->comment($settingKey, false);
$io->simple(Yaml::encode($this->settings->get($settingKey)));
}
$io->newLine();
}
示例15: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$settings = $this->getSettings();
$settingKeys = array_keys($settings->getAll());
$dumper = new Dumper();
$io->newLine();
$io->info($this->trans('commands.settings.debug.messages.current'));
$io->newLine();
foreach ($settingKeys as $settingKey) {
$io->comment($settingKey, false);
$io->simple($dumper->dump($settings->get($settingKey), 10));
}
$io->newLine();
}