当前位置: 首页>>代码示例>>PHP>>正文


PHP DrupalStyle::writeln方法代码示例

本文整理汇总了PHP中Drupal\Console\Style\DrupalStyle::writeln方法的典型用法代码示例。如果您正苦于以下问题:PHP DrupalStyle::writeln方法的具体用法?PHP DrupalStyle::writeln怎么用?PHP DrupalStyle::writeln使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Console\Style\DrupalStyle的用法示例。


在下文中一共展示了DrupalStyle::writeln方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $resource_id = $input->getArgument('resource-id');
     $rest_resources = $this->getRestResources();
     $rest_resources_ids = array_merge(array_keys($rest_resources['enabled']), array_keys($rest_resources['disabled']));
     if (!$resource_id) {
         $resource_id = $io->choiceNoList($this->trans('commands.rest.enable.arguments.resource-id'), $rest_resources_ids);
     }
     $this->validateRestResource($resource_id, $rest_resources_ids, $this->getTranslator());
     $input->setArgument('resource-id', $resource_id);
     // Calculate states available by resource and generate the question
     $plugin = $this->pluginManagerRest->getInstance(['id' => $resource_id]);
     $states = $plugin->availableMethods();
     $state = $io->choice($this->trans('commands.rest.enable.arguments.states'), $states);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-state') . ' ' . $state);
     // Get Authentication Provider and generate the question
     $authenticationProviders = $this->authenticationCollector->getSortedProviders();
     $authenticationProvidersSelected = $io->choice($this->trans('commands.rest.enable.messages.authentication-providers'), array_keys($authenticationProviders), 0, true);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-authentication-providers') . ' ' . implode(', ', $authenticationProvidersSelected));
     $rest_settings = $this->getRestDrupalConfig();
     $rest_settings[$resource_id][$state]['supported_formats'] = $formats;
     $rest_settings[$resource_id][$state]['supported_auth'] = $authenticationProvidersSelected;
     $config = $this->configFactory->getEditable('rest.settings');
     $config->set('resources', $rest_settings);
     $config->save();
     return 0;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:28,代码来源:EnableCommand.php

示例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));
     }
 }
开发者ID:eleaga,项目名称:DrupalConsole,代码行数:30,代码来源:DebugCommand.php

示例3: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $resource_id = $input->getArgument('resource-id');
     $rest_resources = $this->getRestResources();
     $rest_resources_ids = array_merge(array_keys($rest_resources['enabled']), array_keys($rest_resources['disabled']));
     if (!$resource_id) {
         $resource_id = $io->choiceNoList($this->trans('commands.rest.enable.arguments.resource-id'), $rest_resources_ids);
     }
     $this->validateRestResource($resource_id, $rest_resources_ids, $this->getTranslator());
     $input->setArgument('resource-id', $resource_id);
     // Calculate states available by resource and generate the question
     $resourcePluginManager = $this->getPluginManagerRest();
     $plugin = $resourcePluginManager->getInstance(array('id' => $resource_id));
     $states = $plugin->availableMethods();
     $state = $io->choice($this->trans('commands.rest.enable.arguments.states'), $states);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-state') . ' ' . $state);
     // Get serializer formats available and generate the question.
     $serializedFormats = $this->getSerializerFormats();
     $formats = $io->choice($this->trans('commands.rest.enable.messages.formats'), $serializedFormats, 0, true);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-formats') . ' ' . implode(', ', $formats));
     // Get Authentication Provider and generate the question
     $authenticationProviders = $this->getAuthenticationProviders();
     $authenticationProvidersSelected = $io->choice($this->trans('commands.rest.enable.messages.authentication-providers'), array_keys($authenticationProviders), 0, true);
     $io->writeln($this->trans('commands.rest.enable.messages.selected-authentication-providers') . ' ' . implode(', ', $authenticationProvidersSelected));
     $rest_settings = $this->getRestDrupalConfig();
     $rest_settings[$resource_id][$state]['supported_formats'] = $formats;
     $rest_settings[$resource_id][$state]['supported_auth'] = $authenticationProvidersSelected;
     $config = $this->getConfigFactory()->getEditable('rest.settings');
     $config->set('resources', $rest_settings);
     $config->save();
     // Run cache rebuild to enable rest routing
     $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:34,代码来源:EnableCommand.php

示例4: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $key = $input->getArgument('key');
     if ($key) {
         $state = $this->getState();
         $io->writeln(sprintf('<info>%s:</info>', $key));
         $io->writeln(Yaml::encode($state->get($key)));
         return;
     }
     $this->showAllStateKeys($io);
 }
开发者ID:desarrollolibre,项目名称:DrupalConsole,代码行数:15,代码来源:DebugCommand.php

示例5: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $theme = $input->getArgument('theme');
     if (!$theme) {
         $theme_list = [];
         $themes = $this->getThemeHandler()->rebuildThemeData();
         foreach ($themes as $theme_id => $theme) {
             if (!empty($theme->info['hidden'])) {
                 continue;
             }
             if (!empty($theme->status == 0)) {
                 continue;
             }
             $theme_list[$theme_id] = $theme->getName();
         }
         $output->writeln('[+] <info>' . $this->trans('commands.theme.uninstall.messages.installed-themes') . '</info>');
         while (true) {
             $theme_name = $output->choiceNoList($this->trans('commands.theme.uninstall.questions.theme'), array_keys($theme_list));
             if (empty($theme_name)) {
                 break;
             }
             $theme_list_install[] = $theme_name;
             if (array_search($theme_name, $theme_list_install, true) >= 0) {
                 unset($theme_list[$theme_name]);
             }
         }
         $input->setArgument('theme', $theme_list_install);
     }
 }
开发者ID:legovaer,项目名称:DrupalConsole,代码行数:33,代码来源:UninstallCommand.php

示例6: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $module = $input->getArgument('module');
     if (!$module) {
         $moduleList = [];
         $modules = system_rebuild_module_data();
         foreach ($modules as $moduleId => $module) {
             if ($module->status == 1) {
                 continue;
             }
             $moduleList[$moduleId] = $module->info['name'];
         }
         $output->writeln($this->trans('commands.module.install.messages.disabled-modules'));
         while (true) {
             $moduleName = $output->choiceNoList($this->trans('commands.module.install.questions.module'), array_keys($moduleList), null, true);
             if (empty($moduleName)) {
                 break;
             }
             $moduleListInstall[] = $moduleName;
             if (array_search($moduleName, $moduleListInstall, true) >= 0) {
                 unset($moduleList[$moduleName]);
             }
         }
         $input->setArgument('module', $moduleListInstall);
     }
     $overwrite_config = $input->getOption('overwrite-config');
     $input->setOption('overwrite-config', $overwrite_config);
 }
开发者ID:desarrollolibre,项目名称:DrupalConsole,代码行数:32,代码来源:InstallCommand.php

示例7: 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();
 }
开发者ID:shaktik,项目名称:DrupalConsole,代码行数:30,代码来源:AboutCommand.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $this->getDrupalHelper()->loadLegacyFile('/core/includes/utility.inc');
     $validators = $this->getValidator();
     // Get the --cache option and make validation
     $cache = $input->getArgument('cache');
     $validated_cache = $validators->validateCache($cache);
     if (!$validated_cache) {
         $output->error(sprintf($this->trans('commands.cache.rebuild.messages.invalid_cache'), $cache));
         return;
     }
     // Start rebuilding cache
     $output->newLine();
     $output->writeln(sprintf('<comment>%s</comment>', $this->trans('commands.cache.rebuild.messages.rebuild')));
     // Get data needed to rebuild cache
     $kernelHelper = $this->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();
     }
     $output->success($this->trans('commands.cache.rebuild.messages.completed'));
 }
开发者ID:legovaer,项目名称:DrupalConsole,代码行数:30,代码来源:CacheRebuildCommand.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $output->newLine();
     $output->writeln(sprintf('<comment>%s</comment>', $this->trans('commands.router.rebuild.messages.rebuilding')));
     $container = $this->getContainer();
     $router_builder = $container->get('router.builder');
     $router_builder->rebuild();
     $output->success($this->trans('commands.router.rebuild.messages.completed'));
 }
开发者ID:ostark,项目名称:DrupalConsole,代码行数:10,代码来源:RebuildCommand.php

示例10: siteDetail

 /**
  * @param string $target
  */
 private function siteDetail(DrupalStyle $io, $target)
 {
     $application = $this->getApplication();
     if ($application->getConfig()->loadTarget($target)) {
         $targetConfig = $application->getConfig()->getTarget($target);
         $dumper = new Dumper();
         $yaml = $dumper->dump($targetConfig, 5);
         $io->writeln($yaml);
         return;
     }
 }
开发者ID:naveenvalecha,项目名称:DrupalConsole,代码行数:14,代码来源:DebugCommand.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $application = $this->getApplication();
     $aboutTitle = sprintf('%s (%s) | Supports Drupal %s', $this->trans('commands.site.status.messages.console'), $application->getVersion(), $application::DRUPAL_VERSION);
     $output->setDecorated(false);
     $output->title($aboutTitle);
     $output->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_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) {
         $output->writeln($commandInfo[0]);
         $output->newLine();
         $output->writeln(sprintf('  <comment>%s</comment>', $commandInfo[1]));
         $output->newLine();
     }
     $output->setDecorated(false);
     $output->section($this->trans('commands.self-update.description'));
     $output->setDecorated(true);
     $output->writeln('  <comment>drupal self-update</comment>');
     $output->newLine();
 }
开发者ID:dustinleblanc,项目名称:DrupalConsole,代码行数:21,代码来源:AboutCommand.php

示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $directory = sprintf('%s/templates/core/druplicon/', $this->appRoot . DRUPAL_CONSOLE);
     $finder = new Finder();
     $finder->files()->name('*.twig')->in($directory);
     $templates = [];
     foreach ($finder as $template) {
         $templates[] = $template->getRelativePathname();
     }
     $druplicon = $this->renderer->render(sprintf('core/druplicon/%s', $templates[array_rand($templates)]));
     $io->writeln($druplicon);
 }
开发者ID:sanduhrs,项目名称:DrupalConsole,代码行数:13,代码来源:DrupliconCommand.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $renderer = $this->getRenderHelper();
     $directory = sprintf('%stemplates/core/elephpant/', $this->getApplication()->getDirectoryRoot());
     $finder = new Finder();
     $finder->files()->name('*.twig')->in($directory);
     $templates = [];
     foreach ($finder as $template) {
         $templates[] = $template->getRelativePathname();
     }
     $elephpant = $renderer->render(sprintf('core/elephpant/%s', $templates[array_rand($templates)]));
     $io->writeln($elephpant);
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:14,代码来源:ElephpantCommand.php

示例14: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $key = $input->getArgument('key');
     if ($key) {
         $io->info($key);
         $io->writeln(Yaml::encode($this->state->get($key)));
         return 0;
     }
     $tableHeader = [$this->trans('commands.state.debug.messages.key')];
     $keyStoreStates = array_keys($this->keyValue->get('state')->getAll());
     $io->table($tableHeader, $keyStoreStates);
     return 0;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:17,代码来源:DebugCommand.php

示例15: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $directory = $input->getOption('directory');
     $tar = $input->getOption('tar');
     $archiveTar = new ArchiveTar();
     if (!$directory) {
         $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
     }
     if ($tar) {
         if (!is_dir($directory)) {
             mkdir($directory, 0777, true);
         }
         $dateTime = new \DateTime();
         $archiveFile = sprintf('%s/config-%s.tar.gz', $directory, $dateTime->format('Y-m-d-H-i-s'));
         $archiveTar = new ArchiveTar($archiveFile, 'gz');
     }
     try {
         $configManager = $this->getConfigManager();
         // Get raw configuration data without overrides.
         foreach ($configManager->getConfigFactory()->listAll() as $name) {
             $configData = $configManager->getConfigFactory()->get($name)->getRawData();
             $configName = sprintf('%s.yml', $name);
             $ymlData = Yaml::encode($configData);
             if ($tar) {
                 $archiveTar->addString($configName, $ymlData);
                 continue;
             }
             $configFileName = sprintf('%s/%s', $directory, $configName);
             file_put_contents($configFileName, $ymlData);
         }
     } catch (\Exception $e) {
         $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));
     }
     $output->success($this->trans('commands.config.export.messages.directory'));
     $output->writeln($directory);
 }
开发者ID:legovaer,项目名称:DrupalConsole,代码行数:40,代码来源:ExportCommand.php


注:本文中的Drupal\Console\Style\DrupalStyle::writeln方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。