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


PHP DrupalStyle::warning方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $modules = $input->getArgument('module');
     $module_handler = $this->getDrupalService('module_handler');
     $lock = $this->getDrupalService('lock');
     // Try to acquire cron lock.
     if (!$lock->acquire('cron', 900.0)) {
         $io->warning($this->trans('commands.cron.execute.messages.lock'));
         return;
     }
     if (in_array('all', $modules)) {
         $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));
         }
     }
     // Set last time cron was executed
     \Drupal::state()->set('system.cron_last', REQUEST_TIME);
     // Release cron lock.
     $lock->release('cron');
     $this->get('chain_queue')->addCommand('cache:rebuild', ['cache' => 'all']);
     $io->success($this->trans('commands.cron.execute.messages.success'));
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:34,代码来源:ExecuteCommand.php

示例2: 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;
 }
开发者ID:ddrozdik,项目名称:DrupalConsole,代码行数:33,代码来源:ExecuteCommand.php

示例3: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $name = $input->getArgument('name');
     $configFactory = $this->getDrupalService('config.factory');
     $names = $configFactory->listAll();
     if ($name) {
         if (!in_array($name, $names)) {
             $io->warning(sprintf($this->trans('commands.config.override.messages.invalid-name'), $name));
             $name = null;
         }
     }
     if (!$name) {
         $name = $io->choiceNoList($this->trans('commands.config.override.questions.name'), $names);
         $input->setArgument('name', $name);
     }
     $key = $input->getArgument('key');
     if (!$key) {
         $configStorage = $this->getDrupalService('config.storage');
         if ($configStorage->exists($name)) {
             $configuration = $configStorage->read($name);
         }
         $key = $io->choiceNoList($this->trans('commands.config.override.questions.key'), array_keys($configuration));
         $input->setArgument('key', $key);
     }
     $value = $input->getArgument('value');
     if (!$value) {
         $value = $io->ask($this->trans('commands.config.override.questions.value'));
         $input->setArgument('value', $value);
     }
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:34,代码来源:OverrideCommand.php

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

示例5: confirmGeneration

 /**
  * @param DrupalStyle $io
  *
  * @return bool
  */
 public function confirmGeneration(DrupalStyle $io)
 {
     $confirmation = $io->confirm($this->trans('commands.common.questions.confirm'), true);
     if (!$confirmation) {
         $io->warning($this->trans('commands.common.messages.canceled'));
     }
     return $confirmation;
 }
开发者ID:stevepatz,项目名称:DrupalConsole,代码行数:13,代码来源:ConfirmationTrait.php

示例6: doRun

 /**
  * {@inheritdoc}
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->registerCommands();
     parent::doRun($input, $output);
     if ($this->getCommandName($input) == 'list' && $this->container->hasParameter('console.warning')) {
         $io = new DrupalStyle($input, $output);
         $io->warning($this->trans($this->container->getParameter('console.warning')));
     }
 }
开发者ID:jeyram,项目名称:DrupalConsole,代码行数:12,代码来源:Application.php

示例7: doRun

 /**
  * {@inheritdoc}
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->registerGenerators();
     $this->registerCommands();
     $clear = $this->container->get('console.configuration_manager')->getConfiguration()->get('application.clear') ?: false;
     if ($clear === true || $clear === 'true') {
         $output->write(sprintf("c"));
     }
     parent::doRun($input, $output);
     if ($this->getCommandName($input) == 'list' && $this->container->hasParameter('console.warning')) {
         $io = new DrupalStyle($input, $output);
         $io->warning($this->trans($this->container->getParameter('console.warning')));
     }
 }
开发者ID:GDrupal,项目名称:DrupalConsole,代码行数:17,代码来源:Application.php

示例8: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $application = $this->getApplication();
     $pharName = 'drupal.phar';
     $updateStrategy = new GithubStrategy();
     $updateStrategy->setPackageName('drupal/console');
     $updateStrategy->setStability(GithubStrategy::STABLE);
     $updateStrategy->setPharName($pharName);
     $updateStrategy->setCurrentLocalVersion($application::VERSION);
     $updater = new Updater(null, false);
     $updater->setStrategyObject($updateStrategy);
     if ($updater->update()) {
         $output->success(sprintf($this->trans('commands.self-update.messages.success'), $updater->getOldVersion(), $pharName));
     } else {
         $output->warning(sprintf($this->trans('commands.self-update.messages.current-version'), $updater->getOldVersion()));
     }
     $this->getApplication()->setDispatcher(null);
 }
开发者ID:dustinleblanc,项目名称:DrupalConsole,代码行数:22,代码来源:SelfUpdateCommand.php

示例9: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $io->newLine();
     $io->comment($this->trans('commands.node.access.rebuild.messages.rebuild'));
     $batch = $input->getOption('batch');
     try {
         node_access_rebuild($batch);
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return;
     }
     $needs_rebuild = $this->getState()->get('node.node_access_needs_rebuild') ?: false;
     if ($needs_rebuild) {
         $io->warning($this->trans('commands.node.access.rebuild.messages.failed'));
     } else {
         $io->success($this->trans('commands.node.access.rebuild.messages.completed'));
     }
 }
开发者ID:durgeshs,项目名称:DrupalConsole,代码行数:22,代码来源:AccessRebuildCommand.php

示例10: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $modules = $input->getArgument('module');
     $overwriteConfig = $input->getOption('overwrite-config');
     $validator = $this->getValidator();
     $moduleInstaller = $this->getModuleInstaller();
     $invalidModules = $validator->getInvalidModules($modules);
     if ($invalidModules) {
         $io->error(sprintf($this->trans('commands.module.install.messages.missing'), implode(', ', $modules), implode(', ', $invalidModules)));
         return;
     }
     $unInstalledModules = $validator->getUninstalledModules($modules);
     if (!$unInstalledModules) {
         $io->warning($this->trans('commands.module.install.messages.nothing'));
         return;
     }
     $dependencies = $this->calculateDependencies($unInstalledModules);
     $missingDependencies = $validator->getInvalidModules($dependencies);
     if ($missingDependencies) {
         $io->error(sprintf($this->trans('commands.module.install.messages.missing-dependencies'), implode(', ', $modules), implode(', ', $missingDependencies)));
         return true;
     }
     if ($dependencies) {
         if (!$io->confirm(sprintf($this->trans('commands.module.install.messages.dependencies'), implode(', ', $dependencies)), false)) {
             return;
         }
     }
     $moduleList = array_merge($unInstalledModules, $dependencies);
     try {
         $moduleInstaller->install($moduleList);
         $io->success(sprintf($this->trans('commands.module.install.messages.success'), implode(', ', $moduleList)));
     } catch (PreExistingConfigException $e) {
         $this->overwriteConfig($io, $e, $moduleList, $overwriteConfig);
         return;
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return;
     }
     // Run cache rebuild to see changes in Web UI
     $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
 }
开发者ID:tstoeckler,项目名称:DrupalConsole,代码行数:45,代码来源:InstallCommand.php

示例11: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $module = $input->getArgument('module');
     $unInstalledDependencies = $this->calculateDependencies((array) $module);
     if (!$unInstalledDependencies) {
         $io->warning($this->trans('commands.module.install.dependencies.messages.no-depencies'));
         return 0;
     }
     try {
         $io->comment(sprintf($this->trans('commands.module.install.dependencies.messages.installing'), implode(', ', $unInstalledDependencies)));
         drupal_static_reset('system_rebuild_module_data');
         $this->moduleInstaller->install($unInstalledDependencies, true);
         $io->success(sprintf($this->trans('commands.module.install.dependencies.messages.success'), implode(', ', $unInstalledDependencies)));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'all']);
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:23,代码来源:InstallDependencyCommand.php

示例12: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $yaml = new Parser();
     $dumper = new Dumper();
     $settingName = $input->getArgument('setting-name');
     $settingValue = $input->getArgument('setting-value');
     $nestedArray = $this->getNestedArrayHelper();
     $application = $this->getApplication();
     $config = $application->getConfig();
     $userConfigFile = sprintf('%s/.console/config.yml', $config->getUserHomeDir());
     if (!file_exists($userConfigFile)) {
         $io->warning(sprintf($this->trans('commands.settings.set.messages.missing-file'), $userConfigFile));
         return 0;
     }
     try {
         $userConfigFileParsed = $yaml->parse(file_get_contents($userConfigFile));
     } catch (\Exception $e) {
         $io->error($this->trans('commands.settings.set.messages.error-parsing') . ': ' . $e->getMessage());
         return 1;
     }
     $parents = array_merge(['application'], explode(".", $settingName));
     $nestedArray->setValue($userConfigFileParsed, $parents, $settingValue, true);
     try {
         $userConfigFileDump = $dumper->dump($userConfigFileParsed, 10);
     } catch (\Exception $e) {
         $io->error($this->trans('commands.settings.set.messages.error-generating') . ': ' . $e->getMessage());
         return;
     }
     try {
         file_put_contents($userConfigFile, $userConfigFileDump);
     } catch (\Exception $e) {
         $io->error($this->trans('commands.settings.set.messages.error-writing') . ': ' . $e->getMessage());
         return;
     }
     if ($settingName == 'language') {
         $this->getTranslator()->loadResource($settingValue, $application->getDirectoryRoot());
     }
     $io->success(sprintf($this->trans('commands.settings.set.messages.success'), $settingName, $settingValue));
 }
开发者ID:durgeshs,项目名称:DrupalConsole,代码行数:43,代码来源:SetCommand.php

示例13: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new DrupalStyle($input, $output);
     $extension_config = $this->getConfigFactory()->getEditable('core.extension');
     $this->moduleInstaller = $this->getModuleInstaller();
     // Get info about modules available
     $module_data = system_rebuild_module_data();
     $modules = $input->getArgument('module');
     $overwrite_config = $input->getOption('overwrite-config');
     $module_list = array_combine($modules, $modules);
     // Determine if some module request is missing
     if ($missing_modules = array_diff_key($module_list, $module_data)) {
         $output->error(sprintf($this->trans('commands.module.install.messages.missing'), implode(', ', $modules), implode(', ', $missing_modules)));
         return true;
     }
     // Only process currently uninstalled modules.
     $installed_modules = $extension_config->get('module') ?: array();
     if (!($module_list = array_diff_key($module_list, $installed_modules))) {
         $output->warning($this->trans('commands.module.install.messages.nothing'));
         return;
     }
     // Calculate dependencies and missing dependencies
     $dependencies = array();
     $missing_dependencies = array();
     while (list($module) = each($module_list)) {
         foreach (array_keys($module_data[$module]->requires) as $dependency) {
             if (!isset($module_data[$dependency])) {
                 $missing_dependencies[] = $dependency;
             }
             // Skip already installed modules.
             if (!isset($module_list[$dependency]) && !isset($installed_modules[$dependency])) {
                 $module_list[$dependency] = $dependency;
                 $dependencies[] = $dependency;
             }
         }
     }
     // Error if there are missing dependencies
     if (!empty($missing_dependencies)) {
         $output->error(sprintf($this->trans('commands.module.install.messages.missing-dependencies'), implode(', ', $modules), implode(', ', $missing_dependencies)));
         return true;
     }
     // Confirm if user want to install dependencies uninstalled
     if ($dependencies) {
         if (!$output->confirm(sprintf($this->trans('commands.module.install.messages.dependencies'), implode(', ', $dependencies)), false)) {
             return;
         }
     }
     // Installing modules
     try {
         // Install the modules.
         $this->moduleInstaller->install($module_list);
         system_rebuild_module_data();
         $output->success(sprintf($this->trans('commands.module.install.messages.success'), implode(', ', array_merge($modules, $dependencies))));
     } catch (PreExistingConfigException $e) {
         $this->overwriteConfig($e, $module_list, $modules, $dependencies, $overwrite_config, $output);
         return;
     } catch (\Exception $e) {
         $output->error($e->getMessage());
         return;
     }
     // Run cache rebuild to see changes in Web UI
     $this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
 }
开发者ID:desarrollolibre,项目名称:DrupalConsole,代码行数:63,代码来源:InstallCommand.php

示例14: copyExistingInstall

 /**
  * Copies detected default install alters settings.php to fit the new directory.
  *
  * @param DrupalStyle $output
  */
 protected function copyExistingInstall(DrupalStyle $output)
 {
     if (!$this->fs->exists($this->root . '/sites/default/settings.php')) {
         $output->error(sprintf($this->trans('commands.multisite.new.errors.file-missing'), 'sites/default/settings.php'));
         return;
     }
     if ($this->fs->exists($this->root . '/sites/default/files')) {
         try {
             $this->fs->mirror($this->root . '/sites/default/files', $this->root . '/sites/' . $this->subdir . '/files');
         } catch (IOExceptionInterface $e) {
             $output->error(sprintf($this->trans('commands.multisite.new.errors.copy-fail'), 'sites/default/files', 'sites/' . $this->subdir . '/files'));
             return;
         }
     } else {
         $output->warning($this->trans('commands.multisite.new.warnings.missing-files'));
     }
     $settings = file_get_contents($this->root . '/sites/default/settings.php');
     $settings = str_replace('sites/default', 'sites/' . $this->subdir, $settings);
     try {
         $this->fs->dumpFile($this->root . '/sites/' . $this->subdir . '/settings.php', $settings);
     } catch (IOExceptionInterface $e) {
         $output->error(sprintf($this->trans('commands.multisite.new.errors.write-fail'), 'sites/' . $this->subdir . '/settings.php'));
         return;
     }
     $this->chmodSettings($output);
     $output->success(sprintf($this->trans('commands.multisite.new.messages.copy-install'), $this->subdir));
 }
开发者ID:blauerberg,项目名称:DrupalConsole,代码行数:32,代码来源:NewCommand.php


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