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


PHP DrupalStyle::error方法代码示例

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


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

示例1: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $address = $this->validatePort($input->getArgument('address'));
     $finder = new PhpExecutableFinder();
     if (false === ($binary = $finder->find())) {
         $io->error($this->trans('commands.server.errors.binary'));
         return;
     }
     $router = $this->getRouterPath();
     $cli = sprintf('%s %s %s %s', $binary, '-S', $address, $router);
     if ($learning) {
         $io->commentBlock($cli);
     }
     $io->success(sprintf($this->trans('commands.server.messages.executing'), $binary));
     $processBuilder = new ProcessBuilder(explode(' ', $cli));
     $process = $processBuilder->getProcess();
     $process->setWorkingDirectory($this->appRoot);
     if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
         $process->setTty('true');
     } else {
         $process->setTimeout(null);
     }
     $process->run();
     if (!$process->isSuccessful()) {
         $io->error($process->getErrorOutput());
     }
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:32,代码来源:ServerCommand.php

示例2: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $moduleHandler = $this->moduleHandler;
     $moduleHandler->loadInclude('locale', 'inc', 'locale.translation');
     $moduleHandler->loadInclude('locale', 'module');
     $language = $input->getArgument('language');
     $languagesObjects = locale_translatable_language_list();
     $languages = $this->site->getStandardLanguages();
     if (isset($languagesObjects[$language])) {
         $languageEntity = $languagesObjects[$language];
     } elseif (array_search($language, $languages)) {
         $langcode = array_search($language, $languages);
         $languageEntity = $languagesObjects[$langcode];
     } else {
         $io->error(sprintf($this->trans('commands.locale.language.delete.messages.invalid-language'), $language));
         return 1;
     }
     try {
         $configurable_language_storage = $this->entityTypeManager->getStorage('configurable_language');
         $configurable_language_storage->load($languageEntity->getId())->delete();
         $io->info(sprintf($this->trans('commands.locale.language.delete.messages.language-deleted-successfully'), $languageEntity->getName()));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     return 0;
 }
开发者ID:ranqiangjun,项目名称:DrupalConsole,代码行数:28,代码来源:LanguageDeleteCommand.php

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

示例4: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $siteName = $input->getArgument('name');
     $directory = $input->getArgument('directory');
     $fileSystem = $this->get('filesystem');
     if (!$fileSystem->exists($directory)) {
         $io->error(sprintf($this->trans('commands.site.import.local.messages.error-missing'), $directory));
         return 1;
     }
     $drupal = $this->get('site');
     if (!$drupal->isValidRoot($directory)) {
         $io->error(sprintf($this->trans('commands.site.import.local.messages.error-not-drupal'), $directory));
         return 1;
     }
     $environment = $input->getOption('environment') ?: 'local';
     $siteConfig = [$environment => ['root' => $drupal->getRoot(), 'host' => 'local']];
     $yaml = $this->get('yaml');
     $dump = $yaml::dump($siteConfig);
     $config = $this->getApplication()->getConfig();
     $userPath = sprintf('%s/.console/sites', $config->getUserHomeDir());
     $configFile = sprintf('%s/%s.yml', $userPath, $siteName);
     try {
         $fileSystem->dumpFile($configFile, $dump);
     } catch (\Exception $e) {
         $io->error(sprintf($this->trans('commands.site.import.local.messages.error-writing'), $e->getMessage()));
         return 1;
     }
     $io->success(sprintf($this->trans('commands.site.import.local.messages.imported')));
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:33,代码来源:ImportLocalCommand.php

示例5: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $uid = $input->getArgument('uid');
     $account = User::load($uid);
     if (!$account) {
         // Error loading User entity.
         $io->error(sprintf($this->trans('commands.user.login.clear.attempts.errors.invalid-user'), $uid));
         return 1;
     }
     // Define event name and identifier.
     $event = 'user.failed_login_user';
     // Identifier is created by uid and IP address,
     // Then we defined a generic identifier.
     $identifier = "{$account->id()}-";
     // Retrieve current database connection.
     $database = $this->getDrupalService('database');
     $schema = $database->schema();
     $flood = $schema->findTables('flood');
     if (!$flood) {
         $io->error($this->trans('commands.user.login.clear.attempts.errors.no-flood'));
         return 1;
     }
     // Clear login attempts.
     $database->delete('flood')->condition('event', $event)->condition('identifier', $database->escapeLike($identifier) . '%', 'LIKE')->execute();
     // Command executed successful.
     $io->success(sprintf($this->trans('commands.user.login.clear.attempts.messages.successful'), $uid));
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:31,代码来源:LoginCleanAttemptsCommand.php

示例6: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     $address = $input->getArgument('address');
     if (false === strpos($address, ':')) {
         $address = sprintf('%s:8088', $address);
     }
     $finder = new PhpExecutableFinder();
     if (false === ($binary = $finder->find())) {
         $io->error($this->trans('commands.server.errors.binary'));
         return;
     }
     $router = $this->getRouterPath();
     $cli = sprintf('%s %s %s %s', $binary, '-S', $address, $router);
     if ($learning) {
         $io->commentBlock($cli);
     }
     $io->success(sprintf($this->trans('commands.server.messages.executing'), $binary));
     $processBuilder = new ProcessBuilder(explode(' ', $cli));
     $process = $processBuilder->getProcess();
     $process->setWorkingDirectory($this->get('site')->getRoot());
     $process->setTty('true');
     $process->run();
     if (!$process->isSuccessful()) {
         $io->error($process->getErrorOutput());
     }
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:31,代码来源:ServerCommand.php

示例7: clearEvents

 /**
  * @param \Drupal\Console\Style\DrupalStyle $io
  * @param $eventType
  * @param $eventSeverity
  * @param $userId
  * @return bool
  */
 protected function clearEvents(DrupalStyle $io, $eventType, $eventSeverity, $userId)
 {
     $connection = $this->getDatabase();
     $severity = RfcLogLevel::getLevels();
     $query = $connection->delete('watchdog');
     if ($eventType) {
         $query->condition('type', $eventType);
     }
     if ($eventSeverity) {
         if (!in_array($eventSeverity, $severity)) {
             $io->error(sprintf($this->trans('commands.database.log.clear.messages.invalid-severity'), $eventSeverity));
             return false;
         }
         $query->condition('severity', array_search($eventSeverity, $severity));
     }
     if ($userId) {
         $query->condition('uid', $userId);
     }
     $result = $query->execute();
     if (!$result) {
         $io->error($this->trans('commands.database.log.clear.messages.clear-error'));
         return false;
     }
     $io->success($this->trans('commands.database.log.clear.messages.clear-sucess'));
     return true;
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:33,代码来源:LogClearCommand.php

示例8: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $modules = $input->getArgument('module');
     $composer = $input->getOption('composer');
     $simulate = $input->getOption('simulate');
     if (!$composer) {
         $io->error($this->trans('commands.module.update.messages.only-composer'));
         return 1;
     }
     if (!$modules) {
         $io->error($this->trans('commands.module.update.messages.missing-module'));
         return 1;
     }
     if (count($modules) > 1) {
         $modules = " drupal/" . implode(" drupal/", $modules);
     } else {
         $modules = " drupal/" . current($modules);
     }
     if ($composer) {
         // Register composer repository
         $command = "composer config repositories.drupal composer https://packagist.drupal-composer.org";
         $this->shellProcess->exec($command, $this->root);
         $command = 'composer update ' . $modules . ' --optimize-autoloader --prefer-dist --no-dev --root-reqs ';
         if ($simulate) {
             $command .= " --dry-run";
         }
         if ($this->shellProcess->exec($command, $this->root)) {
             $io->success(sprintf($this->trans('commands.module.update.messages.composer'), trim($modules)));
         }
     }
     return 0;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:36,代码来源:UpdateCommand.php

示例9: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $moduleHandler = $this->moduleHandler;
     $moduleHandler->loadInclude('locale', 'inc', 'locale.translation');
     $moduleHandler->loadInclude('locale', 'module');
     $language = $input->getArgument('language');
     $languages = $this->site->getStandardLanguages();
     if (isset($languages[$language])) {
         $langcode = $language;
     } elseif (array_search($language, $languages)) {
         $langcode = array_search($language, $languages);
     } else {
         $io->error(sprintf($this->trans('commands.locale.language.add.messages.invalid-language'), $language));
         return 1;
     }
     try {
         $language = ConfigurableLanguage::createFromLangcode($langcode);
         $language->type = LOCALE_TRANSLATION_REMOTE;
         $language->save();
         $io->info(sprintf($this->trans('commands.locale.language.add.messages.language-add-successfully'), $language->getName()));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     return 0;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:27,代码来源:LanguageAddCommand.php

示例10: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $configName = $input->getArgument('name');
     $fileName = $input->getArgument('file');
     $config = $this->getDrupalService('config.factory')->getEditable($configName);
     $ymlFile = new Parser();
     if (!empty($fileName) && file_exists($fileName)) {
         $value = $ymlFile->parse(file_get_contents($fileName));
     } else {
         $value = $ymlFile->parse(stream_get_contents(fopen("php://stdin", "r")));
     }
     if (empty($value)) {
         $io->error($this->trans('commands.config.import.single.messages.empty-value'));
         return;
     }
     $config->setData($value);
     try {
         $config->save();
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     $io->success(sprintf($this->trans('commands.config.import.single.messages.success'), $configName));
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:28,代码来源:ImportSingleCommand.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $configFactory = $this->getService('config.factory');
     $config = $configFactory->getEditable('system.theme');
     $themeHandler = $this->getService('theme_handler');
     $themeHandler->refreshInfo();
     $theme = $input->getArgument('theme');
     $themes = $themeHandler->rebuildThemeData();
     $themesAvailable = [];
     $themesUninstalled = [];
     $themesUnavailable = [];
     foreach ($theme as $themeName) {
         if (isset($themes[$themeName]) && $themes[$themeName]->status == 1) {
             $themesAvailable[$themeName] = $themes[$themeName]->info['name'];
         } elseif (isset($themes[$themeName]) && $themes[$themeName]->status == 0) {
             $themesUninstalled[] = $themes[$themeName]->info['name'];
         } else {
             $themesUnavailable[] = $themeName;
         }
     }
     if (count($themesAvailable) > 0) {
         try {
             foreach ($themesAvailable as $themeKey => $themeName) {
                 if ($themeKey === $config->get('default')) {
                     $io->error(sprintf($this->trans('commands.theme.uninstall.messages.error-default-theme'), implode(',', $themesAvailable)));
                     return;
                 }
                 if ($themeKey === $config->get('admin')) {
                     $io->error(sprintf($this->trans('commands.theme.uninstall.messages.error-admin-theme'), implode(',', $themesAvailable)));
                     return;
                 }
             }
             $themeHandler->uninstall($theme);
             if (count($themesAvailable) > 1) {
                 $io->info(sprintf($this->trans('commands.theme.uninstall.messages.themes-success'), implode(',', $themesAvailable)));
             } else {
                 $io->info(sprintf($this->trans('commands.theme.uninstall.messages.theme-success'), array_shift($themesAvailable)));
             }
         } catch (UnmetDependenciesException $e) {
             $io->error(sprintf($this->trans('commands.theme.uninstall.messages.dependencies'), $e->getMessage()));
             drupal_set_message($e->getTranslatedMessage($this->getStringTranslation(), $theme), 'error');
         }
     } elseif (empty($themesAvailable) && count($themesUninstalled) > 0) {
         if (count($themesUninstalled) > 1) {
             $io->info(sprintf($this->trans('commands.theme.uninstall.messages.themes-nothing'), implode(',', $themesUninstalled)));
         } else {
             $io->info(sprintf($this->trans('commands.theme.uninstall.messages.theme-nothing'), implode(',', $themesUninstalled)));
         }
     } else {
         if (count($themesUnavailable) > 1) {
             $io->error(sprintf($this->trans('commands.theme.uninstall.messages.themes-missing'), implode(',', $themesUnavailable)));
         } else {
             $io->error(sprintf($this->trans('commands.theme.uninstall.messages.theme-missing'), implode(',', $themesUnavailable)));
         }
     }
     // Run cache rebuild to see changes in Web UI
     $this->get('chain_queue')->addCommand('cache:rebuild', ['cache' => 'all']);
 }
开发者ID:mnico,项目名称:DrupalConsole,代码行数:59,代码来源:UninstallCommand.php

示例12: 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;
 }
开发者ID:vincenzodibiaggio,项目名称:DrupalConsole,代码行数:58,代码来源:NewCommand.php

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

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

示例15: 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;
 }
开发者ID:ibonelli,项目名称:DrupalConsole,代码行数:55,代码来源:NewCommand.php


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